JClassType typeParameter, Class<? extends Annotation> annotation,
List<JField> collection) throws UnableToCompleteException {
for (JClassType classType : inspectedClass.getFlattenedSupertypeHierarchy()) {
for (JField field : classType.getFields()) {
if (field.getAnnotation(annotation) != null) {
JParameterizedType parameterizedType = field.getType().isParameterized();
if (!field.isStatic()
|| parameterizedType == null
|| !type.isAssignableFrom(parameterizedType)
|| !typeParameter.isAssignableFrom(parameterizedType.getTypeArgs()[0])) {
logger.log(
TreeLogger.ERROR, "Found the annotation @" + annotation.getSimpleName()
+ " on the invalid field '" + classType.getName() + "." + field.getName()
+ "'. Field must be static and its type must be " + type.getName()
+ "<" + typeParameter.getName() + ">.", null);