我想在开关案例中调用不同的CompletionStage,我还有其他条件,这些条件将作为案例不断添加,我想获得该特定案例的结果。
下面是代码。
public CompletionStage<HashMap<String,Object>> verifyDetails(Argument1, Argumnet2) {
CompletionStage<JsonNode> js = new CompletableFuture<>();
if(true) {
switch(Expression) {
case "1":
js.thenCompose(cs1 -> {return GetCase1Details()});
break;
case "2":
js.thenCompose(cs1 -> {return getCase2Details()});
break;
}
}
return js.thenApply(fn ->{
System.out.println(fn);
})
}
private CompletionStage<HashMap<String, Object>> GetCase1Details(){
HashMap<String, Object> map = new HashMap<String, Object>();
//Some stuff
return map;
}
private CompletionStage<HashMap<String, Object>> GetCase2Details(){
HashMap<String, Object> map = new HashMap<String, Object>();
//Some stuff
return map;
}