use of scenelib.annotations.field.ScalarAFT in project checker-framework by typetools.
the class AnnotationConverter method getAnnotationFieldType.
/**
* Returns an AnnotationFieldType given an ExecutableElement or value.
*/
protected static AnnotationFieldType getAnnotationFieldType(ExecutableElement ee, Object value) {
if (value instanceof List<?>) {
AnnotationValue defaultValue = ee.getDefaultValue();
if (defaultValue == null || ((ArrayType) ((Array) defaultValue).type) == null) {
List<?> listV = (List<?>) value;
if (!listV.isEmpty()) {
ScalarAFT scalarAFT = (ScalarAFT) getAnnotationFieldType(ee, ((AnnotationValue) listV.get(0)).getValue());
if (scalarAFT != null) {
return new ArrayAFT(scalarAFT);
}
}
return null;
}
Type elemType = ((ArrayType) ((Array) defaultValue).type).elemtype;
try {
return new ArrayAFT(BasicAFT.forType(Class.forName(elemType.toString())));
} catch (ClassNotFoundException e) {
ErrorReporter.errorAbort(e.getMessage());
}
} else if (value instanceof Boolean) {
return BasicAFT.forType(boolean.class);
} else if (value instanceof Character) {
return BasicAFT.forType(char.class);
} else if (value instanceof Double) {
return BasicAFT.forType(double.class);
} else if (value instanceof Float) {
return BasicAFT.forType(float.class);
} else if (value instanceof Integer) {
return BasicAFT.forType(int.class);
} else if (value instanceof Long) {
return BasicAFT.forType(long.class);
} else if (value instanceof Short) {
return BasicAFT.forType(short.class);
} else if (value instanceof String) {
return BasicAFT.forType(String.class);
}
return null;
}
Aggregations