Skip to content

Commit

Permalink
HHH-14529 Clarify that most fields are final in JPAOverriddenAnnotati…
Browse files Browse the repository at this point in the history
…onReader
  • Loading branch information
yrodiere committed Apr 15, 2021
1 parent 2907c95 commit f92275f
Showing 1 changed file with 14 additions and 10 deletions.
Expand Up @@ -238,12 +238,12 @@ private enum PropertyType {
annotationToXml.put( ConstructorResult.class, "constructor-result" );
}

private XMLContext xmlContext;
private final XMLContext xmlContext;
private final ClassLoaderAccess classLoaderAccess;
private final AnnotatedElement element;
private String className;
private String propertyName;
private PropertyType propertyType;
private final String className;
private final String propertyName;
private final PropertyType propertyType;
private transient Annotation[] annotations;
private transient Map<Class, Annotation> annotationsMap;
private transient List<Element> elementsForProperty;
Expand All @@ -263,6 +263,8 @@ public JPAOverriddenAnnotationReader(
if ( el instanceof Class ) {
Class clazz = (Class) el;
className = clazz.getName();
propertyName = null;
propertyType = null;
}
else if ( el instanceof Field ) {
Field field = (Field) el;
Expand All @@ -282,18 +284,18 @@ else if ( el instanceof Field ) {
else if ( el instanceof Method ) {
Method method = (Method) el;
className = method.getDeclaringClass().getName();
propertyName = method.getName();
String methodName = method.getName();

// YUCK! The null here is the 'boundType', we'd rather get the TypeEnvironment()
if ( ReflectionUtil.isProperty( method, null, PersistentAttributeFilter.INSTANCE ) ) {
if ( propertyName.startsWith( "get" ) ) {
propertyName = Introspector.decapitalize( propertyName.substring( "get".length() ) );
if ( methodName.startsWith( "get" ) ) {
propertyName = Introspector.decapitalize( methodName.substring( "get".length() ) );
}
else if ( propertyName.startsWith( "is" ) ) {
propertyName = Introspector.decapitalize( propertyName.substring( "is".length() ) );
else if ( methodName.startsWith( "is" ) ) {
propertyName = Introspector.decapitalize( methodName.substring( "is".length() ) );
}
else {
throw new RuntimeException( "Method " + propertyName + " is not a property getter" );
throw new RuntimeException( "Method " + methodName + " is not a property getter" );
}
propertyType = PropertyType.PROPERTY;
try {
Expand All @@ -304,12 +306,14 @@ else if ( propertyName.startsWith( "is" ) ) {
}
}
else {
propertyName = methodName;
propertyType = PropertyType.METHOD;
}
}
else {
className = null;
propertyName = null;
propertyType = null;
}
}

Expand Down

0 comments on commit f92275f

Please sign in to comment.