V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  xdchl  ›  全部回复第 1 页 / 共 1 页
回复总数  7
据我所知没有,但是目前有混合云多云的解决方案产品。Karmada 华为云开源贡献给 CNCF 基金会的首个多云容器编排项目,目前华为云有基于此提供的多云混合云管理编排解决方案 MCP 。
https://support.huaweicloud.com/productdesc-mcp/mcp_productdesc_0001.html
@xdchl 写完算了
import java.util.HashMap;
import java.util.Map;

public class MutipleIfQuestionFromV2ex {
public int testMethod() {
Map<String, Integer> map1 = new HashMap<>();
Map<String, Integer> map2 = new HashMap<>();
if (map2.get("unitLevel") == null || map1.get("unitLevel") == null) {
// return something according to your business logic
return 0;
} else {
return recursiveCompareLevelCount("countAA", "countAA", map1, map2);
}
}

private int recursiveCompareLevelCount(String key0, String key1, Map<String, Integer> map0, Map<String, Integer> map1) {
// key0 and key1 equals your end compare logic
if (key0.equals("unitScore") && key1.equals("unitScore")) {
return map1.get(key0).compareTo(map0.get(key1));
}

int flag = compareLevelCount(map1.get(key1), map0.get(key0));
if (flag != 0) {
return flag;
} else {
// set some rule to increment the key
char count = (char) (key0.charAt(key0.length() - 1) + 1);
if (count == 'E') {
key0 = "unitScore";
key1 = "unitScore";
} else if (count == 'B' && key0.charAt(key0.length() - 2) == 'A') {
key0 = "countA";
key1 = "countA";
} else {
key0 = key0.substring(0, key0.length() - 1) + count;
key1 = key1.substring(0, key1.length() - 1) + count;
}
return recursiveCompareLevelCount(key0, key1 , map0, map1);
}
}

private int compareLevelCount(int v1, int v2) {
return Integer.compare(v1, v2);
}
}
@xdchl 最后 else 里面是调用 recursiveCompareLevelCount ,打错了
@xdchl 补充,主方法 else 少了个 return
如上面朋友所说,看看 map 的 key 是否能遵从某种逻辑进行变换。可以的话,大体如下
public {returnType} {yourMethodName} ({yourParameters}) {
if (map2.get("unitLevel") == null || map1.get("unitLevel") == null) {
// return something according to your business logic
} else {
recursiveCompareLevelCount("first key0", "first key1", map1, map2);
}
}

private {returnType} recursiveCompareLevelCount(String key0, String key1, Map<K, V> map0, Map<K, V> map1) {
// key0 and key1 equals your end compare logic
if (key0.equals("Something") && key1.equals("Something")) {
return Double.valueOf((Double) map1.get(key0)).compareTo(Double.valueOf((Double) map0.get(key1)));
}

int flag = compareLevelCount((Integer) map1.get(key1), (Integer) map0.get(key0));
if (flag != 0) {
return flag;
} else {
// set some rule to increment the key
return compareLevelCount(new String("increment key0"), new String("increment key1"), map0, map1);
}
}
2022-03-29 11:34:28 +08:00
回复了 linquan 创建的主题 问与答 求推荐良心快餐食品
永和大王
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3313 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 16ms · UTC 12:22 · PVG 20:22 · LAX 04:22 · JFK 07:22
Developed with CodeLauncher
♥ Do have faith in what you're doing.