@Override public String toString() { return "AnnotationReference " + getDataType() + " referring to " + reference; }
@Override public boolean isValueCompatible(FieldValue value) { if (!(value instanceof AnnotationReference)) { return false; } AnnotationReference reference = (AnnotationReference) value; if (equals(reference.getDataType())) { return true; } return false; }
/** * Set an {@link Annotation} that this AnnotationReference shall refer to. * * @param reference an Annotation that this AnnotationReference shall refer to. * @throws IllegalArgumentException if the given annotation has a type that is not compatible with this reference */ public void setReference(Annotation reference) { if (reference == null) { this.reference = null; return; } AnnotationReferenceDataType type = getDataType(); if (type.getAnnotationType().isValueCompatible(reference) // The case if concrete annotation type || reference.getType() instanceof AnnotationType) { this.reference = reference; } else { throw new IllegalArgumentException("Cannot set reference, must be of type " + type + " (was of type " + reference.getType() + ")"); } }