I want to create JCodeModel for the below method:
private static Optional<Class<?>> getTypeOfId(String fieldName) {
switch (fieldName.toLowerCase()) {
case "IDFORCLASSX":
{
return Optional.of(X.class);
}
default:
{
return Optional.empty();
}
}
}
I am presently using below code for creating the return type of the class.
AbstractJClass optionalOfClassType = codeModel.ref(Optional.class)
.narrow(codeModel.ref(Class.class)
.narrow(codeModel.ref("?")));
But the above code gives a high priority FindBug error PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS
.
Can anyone help me to optimize the above line of code?
Aucun commentaire:
Enregistrer un commentaire