@@ -156,7 +156,7 @@ private void addAuxiliaryMembersForRepeatableAnnotation(String annotationName, S
156156 final List <? extends AnnotationValue > annotationValues =
157157 (List <? extends AnnotationValue >) value .getValue ();
158158 for ( AnnotationValue annotationValue : annotationValues ) {
159- addAuxiliaryMembersForMirror ( (AnnotationMirror ) annotationValue .getValue (), prefix );
159+ addAuxiliaryMembersForMirror ( (AnnotationMirror ) annotationValue .getValue (), prefix , annotationName );
160160 }
161161 }
162162 }
@@ -165,21 +165,32 @@ private void addAuxiliaryMembersForRepeatableAnnotation(String annotationName, S
165165 private void addAuxiliaryMembersForAnnotation (String annotationName , String prefix ) {
166166 final AnnotationMirror mirror = getAnnotationMirror ( getElement (), annotationName );
167167 if ( mirror != null ) {
168- addAuxiliaryMembersForMirror ( mirror , prefix );
168+ addAuxiliaryMembersForMirror ( mirror , prefix , annotationName );
169169 }
170170 }
171171
172- private void addAuxiliaryMembersForMirror (AnnotationMirror mirror , String prefix ) {
172+ private void addAuxiliaryMembersForMirror (AnnotationMirror mirror , String prefix , String annotationName ) {
173173 if ( !isJakartaDataStyle () ) {
174- mirror .getElementValues ().forEach ((key , value ) -> {
175- if ( key .getSimpleName ().contentEquals ("name" ) ) {
176- final String name = value .getValue ().toString ();
177- if ( !name .isEmpty () ) {
178- putMember ( prefix + name , auxiliaryMember ( mirror , prefix , name ) );
179- }
180- }
181- });
174+ final String name = defaultImplicitName ( annotationName , explicitName ( mirror ) );
175+ putMember ( prefix + name , auxiliaryMember ( mirror , prefix , name ) );
176+ }
177+ }
178+
179+ private static String explicitName (AnnotationMirror mirror ) {
180+ for ( var entry : mirror .getElementValues ().entrySet () ) {
181+ if ( entry .getKey ().getSimpleName ().contentEquals ( "name" ) ) {
182+ return entry .getValue ().getValue ().toString ();
183+ }
182184 }
185+ return "" ;
186+ }
187+
188+ private String defaultImplicitName (String annotationName , String explicitName ) {
189+ return explicitName .isEmpty ()
190+ && ( Constants .NAMED_ENTITY_GRAPH .equals ( annotationName )
191+ || Constants .NAMED_ENTITY_GRAPHS .equals ( annotationName ) )
192+ ? getSimpleName ()
193+ : explicitName ;
183194 }
184195
185196 private NameMetaAttribute auxiliaryMember (AnnotationMirror mirror , String prefix , String name ) {
0 commit comments