HHH-17165 fix isGetter(), isSetter() in AnnotationMetaEntity
This commit is contained in:
parent
81a7898162
commit
412217d011
|
@ -386,15 +386,25 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
|| isGetter( methodSimpleName, methodParameterTypes, returnType );
|
|| isGetter( methodSimpleName, methodParameterTypes, returnType );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isGetter(Name methodSimpleName, List<? extends TypeMirror> methodParameterTypes, TypeMirror returnType) {
|
private static boolean hasPrefix(Name methodSimpleName, String prefix) {
|
||||||
return ( methodSimpleName.subSequence(0,3).toString().equals("get")
|
return methodSimpleName.length() > prefix.length()
|
||||||
|| methodSimpleName.subSequence(0,2).toString().equals("is") )
|
&& methodSimpleName.subSequence( 0, prefix.length() ).toString().equals( prefix );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isGetter(
|
||||||
|
Name methodSimpleName,
|
||||||
|
List<? extends TypeMirror> methodParameterTypes,
|
||||||
|
TypeMirror returnType) {
|
||||||
|
return ( hasPrefix( methodSimpleName, "get" ) || hasPrefix( methodSimpleName,"is" ) )
|
||||||
&& methodParameterTypes.isEmpty()
|
&& methodParameterTypes.isEmpty()
|
||||||
&& returnType.getKind() != TypeKind.VOID;
|
&& returnType.getKind() != TypeKind.VOID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSetter(Name methodSimpleName, List<? extends TypeMirror> methodParameterTypes, TypeMirror returnType) {
|
private static boolean isSetter(
|
||||||
return methodSimpleName.subSequence(0,3).toString().equals("set")
|
Name methodSimpleName,
|
||||||
|
List<? extends TypeMirror> methodParameterTypes,
|
||||||
|
TypeMirror returnType) {
|
||||||
|
return hasPrefix( methodSimpleName, "set")
|
||||||
&& methodParameterTypes.size() == 1
|
&& methodParameterTypes.size() == 1
|
||||||
&& returnType.getKind() != TypeKind.VOID;
|
&& returnType.getKind() != TypeKind.VOID;
|
||||||
}
|
}
|
||||||
|
@ -905,17 +915,15 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean fieldMatches(String token, Name fieldName) {
|
private static boolean fieldMatches(String token, Name fieldName) {
|
||||||
return fieldName.contentEquals(token);
|
return fieldName.contentEquals( token );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean getterMatches(String token, Name methodName) {
|
private static boolean getterMatches(String token, Name methodName) {
|
||||||
if ( methodName.length() > 3 && methodName.subSequence(0,3).toString().equals("get")) {
|
if ( hasPrefix( methodName, "get" ) ) {
|
||||||
final String propertyName = decapitalize(methodName.subSequence(3, methodName.length()).toString());
|
return token.equals( decapitalize( methodName.subSequence( 3, methodName.length()).toString() ) );
|
||||||
return token.equals(propertyName);
|
|
||||||
}
|
}
|
||||||
else if ( methodName.length() > 2 && methodName.subSequence(0,2).toString().equals("is")) {
|
else if ( hasPrefix( methodName, "is" ) ) {
|
||||||
final String propertyName = decapitalize(methodName.subSequence(2, methodName.length()).toString());
|
return token.equals( decapitalize( methodName.subSequence( 2, methodName.length() ).toString() ) );
|
||||||
return token.equals(propertyName);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue