squash some warnings in AnnotationMetaEntity
This commit is contained in:
parent
e13efce86b
commit
79d3a3410d
|
@ -1013,14 +1013,11 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
private boolean compatibleAccess(TypeElement assocTypeElement, Element member) {
|
private boolean compatibleAccess(TypeElement assocTypeElement, Element member) {
|
||||||
final AccessType memberAccessType = determineAnnotationSpecifiedAccessType( member );
|
final AccessType memberAccessType = determineAnnotationSpecifiedAccessType( member );
|
||||||
final AccessType accessType = memberAccessType == null ? getAccessType(assocTypeElement) : memberAccessType;
|
final AccessType accessType = memberAccessType == null ? getAccessType(assocTypeElement) : memberAccessType;
|
||||||
switch ( member.getKind() ) {
|
return switch ( member.getKind() ) {
|
||||||
case FIELD:
|
case FIELD -> accessType == AccessType.FIELD;
|
||||||
return accessType == AccessType.FIELD;
|
case METHOD -> accessType == AccessType.PROPERTY;
|
||||||
case METHOD:
|
default -> false;
|
||||||
return accessType == AccessType.PROPERTY;
|
};
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateBackRef(
|
private void validateBackRef(
|
||||||
|
@ -1443,15 +1440,12 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
switch ( parameterType.getKind() ) {
|
switch ( parameterType.getKind() ) {
|
||||||
case DECLARED:
|
case DECLARED:
|
||||||
final DeclaredType declaredType = (DeclaredType) parameterType;
|
final DeclaredType declaredType = (DeclaredType) parameterType;
|
||||||
List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
|
final List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
|
||||||
switch ( typeArguments.size() ) {
|
return switch ( typeArguments.size() ) {
|
||||||
case 1:
|
case 1 -> typeArguments.get(0);
|
||||||
return typeArguments.get(0);
|
case 2 -> typeArguments.get(1);
|
||||||
case 2:
|
default -> null;
|
||||||
return typeArguments.get(1);
|
};
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
case ARRAY:
|
case ARRAY:
|
||||||
final ArrayType arrayType = (ArrayType) parameterType;
|
final ArrayType arrayType = (ArrayType) parameterType;
|
||||||
return arrayType.getComponentType();
|
return arrayType.getComponentType();
|
||||||
|
@ -1773,17 +1767,11 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSessionVariableName(String sessionType) {
|
private String getSessionVariableName(String sessionType) {
|
||||||
switch (sessionType) {
|
return switch (sessionType) {
|
||||||
case HIB_SESSION:
|
case HIB_SESSION, HIB_STATELESS_SESSION, MUTINY_SESSION, MUTINY_STATELESS_SESSION -> "session";
|
||||||
case HIB_STATELESS_SESSION:
|
// case UNI_MUTINY_SESSION, UNI_MUTINY_STATELESS_SESSION -> "session";
|
||||||
case MUTINY_SESSION:
|
default -> sessionGetter;
|
||||||
case MUTINY_STATELESS_SESSION:
|
};
|
||||||
// case UNI_MUTINY_SESSION:
|
|
||||||
// case UNI_MUTINY_STATELESS_SESSION:
|
|
||||||
return "session";
|
|
||||||
default:
|
|
||||||
return sessionGetter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> enabledFetchProfiles(ExecutableElement method) {
|
private static List<String> enabledFetchProfiles(ExecutableElement method) {
|
||||||
|
@ -1972,17 +1960,16 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
return FieldType.BASIC;
|
return FieldType.BASIC;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (fieldType) {
|
return switch (fieldType) {
|
||||||
case ID:
|
case ID ->
|
||||||
// no byId() API for SS or M.S, only get()
|
// no byId() API for SS or M.S, only get()
|
||||||
return FieldType.ID;
|
FieldType.ID;
|
||||||
case NATURAL_ID:
|
case NATURAL_ID ->
|
||||||
// no byNaturalId() lookup API for SS
|
// no byNaturalId() lookup API for SS
|
||||||
// no byNaturalId() in M.S, but we do have Identifier workaround
|
// no byNaturalId() in M.S, but we do have Identifier workaround
|
||||||
return FieldType.NATURAL_ID;
|
FieldType.NATURAL_ID;
|
||||||
default:
|
default -> FieldType.BASIC;
|
||||||
return FieldType.BASIC;
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2546,12 +2533,10 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
returnTypeCorrect = false;
|
returnTypeCorrect = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( selection instanceof JpaEntityJoin ) {
|
else if ( selection instanceof JpaEntityJoin<?, ?> from ) {
|
||||||
final JpaEntityJoin<?,?> from = (JpaEntityJoin<?,?>) selection;
|
|
||||||
returnTypeCorrect = checkReturnedEntity( from.getModel(), returnType );
|
returnTypeCorrect = checkReturnedEntity( from.getModel(), returnType );
|
||||||
}
|
}
|
||||||
else if ( selection instanceof JpaRoot ) {
|
else if ( selection instanceof JpaRoot<?> from ) {
|
||||||
final JpaRoot<?> from = (JpaRoot<?>) selection;
|
|
||||||
returnTypeCorrect = checkReturnedEntity( from.getModel(), returnType );
|
returnTypeCorrect = checkReturnedEntity( from.getModel(), returnType );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2810,26 +2795,17 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable String fromPrimitive(String argType) {
|
private static @Nullable String fromPrimitive(String argType) {
|
||||||
switch (argType) {
|
return switch (argType) {
|
||||||
case "boolean":
|
case "boolean" -> Boolean.class.getName();
|
||||||
return Boolean.class.getName();
|
case "char" -> Character.class.getName();
|
||||||
case "char":
|
case "int" -> Integer.class.getName();
|
||||||
return Character.class.getName();
|
case "long" -> Long.class.getName();
|
||||||
case "int":
|
case "short" -> Short.class.getName();
|
||||||
return Integer.class.getName();
|
case "byte" -> Byte.class.getName();
|
||||||
case "long":
|
case "float" -> Float.class.getName();
|
||||||
return Long.class.getName();
|
case "double" -> Double.class.getName();
|
||||||
case "short":
|
default -> null;
|
||||||
return Short.class.getName();
|
};
|
||||||
case "byte":
|
|
||||||
return Byte.class.getName();
|
|
||||||
case "float":
|
|
||||||
return Float.class.getName();
|
|
||||||
case "double":
|
|
||||||
return Double.class.getName();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Boolean> parameterNullability(ExecutableElement method, TypeElement entity) {
|
private List<Boolean> parameterNullability(ExecutableElement method, TypeElement entity) {
|
||||||
|
@ -2866,8 +2842,9 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
private TypeMirror parameterType(VariableElement parameter) {
|
private TypeMirror parameterType(VariableElement parameter) {
|
||||||
final ExecutableElement method =
|
final ExecutableElement method =
|
||||||
(ExecutableElement) parameter.getEnclosingElement();
|
(ExecutableElement) parameter.getEnclosingElement();
|
||||||
final TypeMirror type = memberMethodType(method).getParameterTypes()
|
final TypeMirror type =
|
||||||
.get( method.getParameters().indexOf(parameter) );
|
memberMethodType(method).getParameterTypes()
|
||||||
|
.get( method.getParameters().indexOf(parameter) );
|
||||||
switch ( type.getKind() ) {
|
switch ( type.getKind() ) {
|
||||||
case TYPEVAR:
|
case TYPEVAR:
|
||||||
final TypeVariable typeVariable = (TypeVariable) type;
|
final TypeVariable typeVariable = (TypeVariable) type;
|
||||||
|
@ -3077,17 +3054,11 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLocal(Element methodOrParam) {
|
private boolean isLocal(Element methodOrParam) {
|
||||||
switch (methodOrParam.getKind()) {
|
return switch ( methodOrParam.getKind() ) {
|
||||||
case PARAMETER:
|
case PARAMETER -> element.getEnclosedElements().contains( methodOrParam.getEnclosingElement() );
|
||||||
return element.getEnclosedElements()
|
case METHOD, FIELD -> element.getEnclosedElements().contains( methodOrParam );
|
||||||
.contains( methodOrParam.getEnclosingElement() );
|
default -> true;
|
||||||
case METHOD:
|
};
|
||||||
case FIELD:
|
|
||||||
return element.getEnclosedElements()
|
|
||||||
.contains( methodOrParam );
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void message(Element method, String message, Diagnostic.Kind severity) {
|
public void message(Element method, String message, Diagnostic.Kind severity) {
|
||||||
|
|
Loading…
Reference in New Issue