static boolean isBindingAnnotation(Annotation annotation) { return isBindingAnnotation(annotation.annotationType()); }
private static void ensureIsBindingAnnotation( Class<? extends Annotation> annotationType) { if (!isBindingAnnotation(annotationType)) { throw new IllegalArgumentException(annotationType.getName() + " is not a binding annotation." + " Please annotate it with @BindingAnnotation."); } }
void validateAnnotation(Class<? extends Annotation> annotationType) { if (annotationStrategy != null) { binder.addError(source, ErrorMessages.ANNOTATION_ALREADY_SPECIFIED); return; } boolean retainedAtRuntime = Annotations.isRetainedAtRuntime(annotationType); boolean bindingAnnotation = Key.isBindingAnnotation(annotationType); if (!retainedAtRuntime) { binder.addError(StackTraceElements.forType(annotationType), ErrorMessages.MISSING_RUNTIME_RETENTION, source); } if (!bindingAnnotation) { binder.addError(StackTraceElements.forType(annotationType), ErrorMessages.MISSING_BINDING_ANNOTATION, source); } }
public BindingBuilderImpl<T> annotatedWith(Annotation annotation) { if (this.key.hasAnnotationType()) { binder.addError(source, ErrorMessages.ANNOTATION_ALREADY_SPECIFIED); } else { Class<? extends Annotation> annotationType = annotation.annotationType(); boolean retainedAtRuntime = Annotations.isRetainedAtRuntime(annotationType); boolean bindingAnnotation = Key.isBindingAnnotation(annotationType); if (!retainedAtRuntime) { binder.addError(StackTraceElements.forType(annotationType), ErrorMessages.MISSING_RUNTIME_RETENTION, binder.source()); } if (!bindingAnnotation) { binder.addError(StackTraceElements.forType(annotationType), ErrorMessages.MISSING_BINDING_ANNOTATION, binder.source()); } if (retainedAtRuntime && bindingAnnotation) { this.key = Key.get(this.key.getTypeLiteral(), annotation); } } return this; }
public BindingBuilderImpl<T> annotatedWith( Class<? extends Annotation> annotationType) { if (this.key.hasAnnotationType()) { binder.addError(source, ErrorMessages.ANNOTATION_ALREADY_SPECIFIED); } else { boolean retainedAtRuntime = Annotations.isRetainedAtRuntime(annotationType); boolean bindingAnnotation = Key.isBindingAnnotation(annotationType); if (!retainedAtRuntime) { binder.addError(StackTraceElements.forType(annotationType), ErrorMessages.MISSING_RUNTIME_RETENTION, binder.source()); } if (!bindingAnnotation) { binder.addError(StackTraceElements.forType(annotationType), ErrorMessages.MISSING_BINDING_ANNOTATION, binder.source()); } if (retainedAtRuntime && bindingAnnotation) { this.key = Key.get(this.key.getTypeLiteral(), annotationType); } } return this; }