From 8992cbbbded962b673ac6b8390bb1c56a30303e1 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Tue, 2 Apr 2024 10:48:37 +0200 Subject: [PATCH] simplification, use getAllMembers() in processor Signed-off-by: Gavin King --- .../annotation/AnnotationMetaEntity.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java index d18045c55e..574c4a3651 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java @@ -379,8 +379,8 @@ public class AnnotationMetaEntity extends AnnotationMeta { final List lifecycleMethods = new ArrayList<>(); if ( repository ) { - final List methodsOfClass = new ArrayList<>(); - addMethods( element, methodsOfClass ); + final List methodsOfClass = + methodsIn( context.getElementUtils().getAllMembers(element) ); for ( ExecutableElement method: methodsOfClass ) { if ( containsAnnotation( method, HQL, SQL, JD_QUERY, FIND, JD_FIND ) ) { queryMethods.add( method ); @@ -396,8 +396,9 @@ public class AnnotationMetaEntity extends AnnotationMeta { queryMethods.add( method ); } } - else if ( !isSessionGetter(method) - && !method.getModifiers().contains(Modifier.DEFAULT) ) { + else if ( method.getEnclosingElement().getKind().isInterface() + && !method.isDefault() + && !isSessionGetter(method) ) { final String companionClassName = element.getQualifiedName().toString() + '$'; if ( context.getElementUtils().getTypeElement(companionClassName) == null ) { message( method, "repository method cannot be implemented", @@ -498,19 +499,6 @@ public class AnnotationMetaEntity extends AnnotationMeta { return result; } - private void addMethods(TypeElement element, List methodsOfClass) { - //TODO just use Elements.getAllMembers(element) here! - for ( TypeMirror typeMirror : element.getInterfaces() ) { - final DeclaredType declaredType = (DeclaredType) typeMirror; - final TypeElement typeElement = (TypeElement) declaredType.asElement(); - addMethods( typeElement, methodsOfClass ); - } - for ( ExecutableElement method : methodsIn( element.getEnclosedElements() ) ) { - methodsOfClass.removeIf( m -> context.getElementUtils().overrides(method, m, element) ); - methodsOfClass.add( method ); - } - } - private void addDefaultConstructor() { final String sessionVariableName = getSessionVariableName(sessionType); putMember("_", new DefaultConstructor(