mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 22:15:11 +00:00
Use chainDots to generate java.lang.Object to get rid of the extra prepended dot!
Change the order of the generated methods, first equals then hashCode
This commit is contained in:
1 parent
f05facd457
commit
e3d9e116af
1 file changed
+16
-16
@@ -167,21 +167,6 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
|
||||
}
|
||||
}
|
||||
|
||||
switch (methodExists("hashCode", typeNode)) {
|
||||
case NOT_EXISTS:
|
||||
JCMethodDecl method = createHashCode(typeNode, nodesForEquality, callSuper);
|
||||
injectMethod(typeNode, method);
|
||||
break;
|
||||
case EXISTS_BY_LOMBOK:
|
||||
break;
|
||||
default:
|
||||
case EXISTS_BY_USER:
|
||||
if (whineIfExists) {
|
||||
errorNode.addWarning("Not generating hashCode(): A method with that name already exists");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (methodExists("equals", typeNode)) {
|
||||
case NOT_EXISTS:
|
||||
JCMethodDecl method = createEquals(typeNode, nodesForEquality, callSuper);
|
||||
@@ -197,6 +182,21 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
|
||||
break;
|
||||
}
|
||||
|
||||
switch (methodExists("hashCode", typeNode)) {
|
||||
case NOT_EXISTS:
|
||||
JCMethodDecl method = createHashCode(typeNode, nodesForEquality, callSuper);
|
||||
injectMethod(typeNode, method);
|
||||
break;
|
||||
case EXISTS_BY_LOMBOK:
|
||||
break;
|
||||
default:
|
||||
case EXISTS_BY_USER:
|
||||
if (whineIfExists) {
|
||||
errorNode.addWarning("Not generating hashCode(): A method with that name already exists");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
|
||||
|
||||
JCAnnotation overrideAnnotation = maker.Annotation(chainDots(maker, typeNode, "java", "lang", "Override"), List.<JCExpression>nil());
|
||||
JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation));
|
||||
JCExpression objectType = maker.Type(typeNode.getSymbolTable().objectType);
|
||||
JCExpression objectType = chainDots(maker, typeNode, "java", "lang", "Object");
|
||||
JCExpression returnType = maker.TypeIdent(TypeTags.BOOLEAN);
|
||||
|
||||
List<JCStatement> statements = List.nil();
|
||||
|
||||
Reference in new issue
Block a user