return new AnnotationEnumValue(className, constName);
/** * Get the enum constant. Causes the ClassLoader to load the enum class. * * @return A ref to the enum constant value. * @throws IllegalArgumentException * if the class could not be loaded, or the enum constant is invalid. */ public Object getEnumValueRef() throws IllegalArgumentException { final Class<?> classRef = scanResult.classNameToClassRef(className); if (!classRef.isEnum()) { throw new IllegalArgumentException("Class " + className + " is not an enum"); } Field field; try { field = classRef.getDeclaredField(constName); } catch (NoSuchFieldException | SecurityException e) { throw new IllegalArgumentException("Could not find enum constant " + toString(), e); } if (!field.isEnumConstant()) { throw new IllegalArgumentException("Field " + toString() + " is not an enum constant"); } try { return field.get(null); } catch (final IllegalAccessException e) { throw new IllegalArgumentException("Field " + toString() + " is not accessible", e); } }
@Override void setScanResult(final ScanResult scanResult) { if (annotationValueArray != null) { for (int i = 0; i < annotationValueArray.length; i++) { if (annotationValueArray[i] != null) { annotationValueArray[i].setScanResult(scanResult); } } } else if (annotationEnumValue != null) { annotationEnumValue.setScanResult(scanResult); } else if (annotationClassRef != null) { annotationClassRef.setScanResult(scanResult); } else if (annotationInfo != null) { annotationInfo.setScanResult(scanResult); } } }
@Override public boolean equals(final Object o) { if (!(o instanceof AnnotationEnumValue)) { return false; } return compareTo((AnnotationEnumValue) o) == 0; }