Skip to content

Commit

Permalink
simplification, use getAllMembers() in processor
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin King <gavin@hibernate.org>
  • Loading branch information
gavinking committed Apr 2, 2024
1 parent f51d8db commit 8992cbb
Showing 1 changed file with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ protected final void init() {
final List<ExecutableElement> lifecycleMethods = new ArrayList<>();

if ( repository ) {
final List<ExecutableElement> methodsOfClass = new ArrayList<>();
addMethods( element, methodsOfClass );
final List<ExecutableElement> methodsOfClass =
methodsIn( context.getElementUtils().getAllMembers(element) );
for ( ExecutableElement method: methodsOfClass ) {
if ( containsAnnotation( method, HQL, SQL, JD_QUERY, FIND, JD_FIND ) ) {
queryMethods.add( method );
Expand All @@ -396,8 +396,9 @@ else if ( hasAnnotation( method, JD_DELETE ) ) {
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",
Expand Down Expand Up @@ -498,19 +499,6 @@ private void validateStatelessSessionType() {
return result;
}

private void addMethods(TypeElement element, List<ExecutableElement> 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(
Expand Down

0 comments on commit 8992cbb

Please sign in to comment.