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(" }");
|
pw.println(" }");
|
||||||
});
|
});
|
||||||
|
|
||||||
FieldAccessorType.getMethod(FieldAccessorType.MAP_ADD, methods, fieldName, types, fieldType).ifPresent(method -> {
|
FieldAccessorType.getMethod(FieldAccessorType.GETTER, methods, fieldName, types, fieldType).ifPresent(method -> {
|
||||||
TypeMirror firstParameterType = method.getParameters().get(0).asType();
|
if (Util.isMapType((TypeElement) types.asElement(types.erasure(fieldType)))) {
|
||||||
TypeMirror secondParameterType = method.getParameters().get(1).asType();
|
TypeMirror firstParameterType = Util.getGenericsDeclaration(method.getReturnType()).get(0);
|
||||||
pw.println(" @SuppressWarnings(\"unchecked\") @Override public Class<?> getMapKeyClass() {");
|
TypeMirror secondParameterType = Util.getGenericsDeclaration(method.getReturnType()).get(1);
|
||||||
pw.println(" return " + types.erasure(firstParameterType) + ".class;");
|
|
||||||
pw.println(" }");
|
pw.println(" @SuppressWarnings(\"unchecked\") @Override public Class<?> getMapKeyClass() {");
|
||||||
pw.println(" @SuppressWarnings(\"unchecked\") @Override public Class<?> getMapValueClass() {");
|
pw.println(" return " + types.erasure(firstParameterType) + ".class;");
|
||||||
pw.println(" return " + types.erasure(secondParameterType) + ".class;");
|
pw.println(" }");
|
||||||
pw.println(" }");
|
pw.println(" @SuppressWarnings(\"unchecked\") @Override public Class<?> getMapValueClass() {");
|
||||||
|
pw.println(" return " + types.erasure(secondParameterType) + ".class;");
|
||||||
|
pw.println(" }");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (ExecutableElement ee : methods) {
|
for (ExecutableElement ee : methods) {
|
||||||
|
|
Loading…
Reference in a new issue