Generate getMapKeyClass and getMapValueClass methods for map fields
Closes #16053
This commit is contained in:
parent
d763feddcd
commit
44715fe397
1 changed files with 12 additions and 9 deletions
|
@ -184,15 +184,18 @@ public class GenerateEntityImplementationsProcessor extends AbstractGenerateEnti
|
|||
pw.println(" }");
|
||||
});
|
||||
|
||||
FieldAccessorType.getMethod(FieldAccessorType.MAP_ADD, methods, fieldName, types, fieldType).ifPresent(method -> {
|
||||
TypeMirror firstParameterType = method.getParameters().get(0).asType();
|
||||
TypeMirror secondParameterType = method.getParameters().get(1).asType();
|
||||
FieldAccessorType.getMethod(FieldAccessorType.GETTER, methods, fieldName, types, fieldType).ifPresent(method -> {
|
||||
if (Util.isMapType((TypeElement) types.asElement(types.erasure(fieldType)))) {
|
||||
TypeMirror firstParameterType = Util.getGenericsDeclaration(method.getReturnType()).get(0);
|
||||
TypeMirror secondParameterType = Util.getGenericsDeclaration(method.getReturnType()).get(1);
|
||||
|
||||
pw.println(" @SuppressWarnings(\"unchecked\") @Override public Class<?> getMapKeyClass() {");
|
||||
pw.println(" return " + types.erasure(firstParameterType) + ".class;");
|
||||
pw.println(" }");
|
||||
pw.println(" @SuppressWarnings(\"unchecked\") @Override public Class<?> getMapValueClass() {");
|
||||
pw.println(" return " + types.erasure(secondParameterType) + ".class;");
|
||||
pw.println(" }");
|
||||
}
|
||||
});
|
||||
|
||||
for (ExecutableElement ee : methods) {
|
||||
|
|
Loading…
Reference in a new issue