@Test public void testGetComponentDefinition_MethodAnnotatedWithoutComponentAnnotation() throws Exception { Method method = ClassWithComponentAnnotatedAnnotations.class.getMethod("annotatedWithoutComponent"); AnnotationWithoutComponentAnnotation annotation = method .getAnnotation(AnnotationWithoutComponentAnnotation.class); try { ComponentAnnotationReader.getComponentDefinition(annotation, method); fail("expected an " + IllegalArgumentException.class.getSimpleName()); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString(AnnotationWithoutComponentAnnotation.class.getSimpleName())); assertThat(e.getMessage(), containsString("annotatedWithoutComponent")); assertThat(e.getMessage(), containsString("isComponentDefinition")); } }
public static <A extends Annotation> LinkkiComponentDefinition getComponentDefinition( A annotation, AnnotatedElement annotatedElement) { LinkkiComponent linkkiComponent = LINKKI_COMPONENT_ANNOTATION.findOn(annotation) .orElseThrow(LINKKI_COMPONENT_ANNOTATION .missingAnnotation(annotation, annotatedElement, ComponentAnnotationReader.class.getSimpleName() + "#isComponentDefinition(Annotation)")); @SuppressWarnings("unchecked") Class<ComponentDefinitionCreator<A>> creatorClass = (Class<ComponentDefinitionCreator<A>>)linkkiComponent .value(); return Classes.instantiate(creatorClass).create(annotation, annotatedElement); }
ComponentAnnotationReader { public static <A extends Annotation> LinkkiComponentDefinition getComponentDefinition( A annotation, AnnotatedElement annotatedElement) { LinkkiComponent linkkiComponent = LINKKI_COMPONENT_ANNOTATION.findOn(annotation) .orElseThrow(LINKKI_COMPONENT_ANNOTATION .missingAnnotation(annotation, annotatedElement, ComponentAnnotationReader.class.getSimpleName() + "#isComponentDefinition(Annotation)")); @SuppressWarnings("unchecked") Class<ComponentDefinitionCreator<A>> creatorClass = (Class<ComponentDefinitionCreator<A>>)linkkiComponent .value(); return Classes.instantiate(creatorClass).create(annotation, annotatedElement); } }
ComponentAnnotationReader { public static <A extends Annotation> LinkkiComponentDefinition getComponentDefinition( A annotation, AnnotatedElement annotatedElement) { LinkkiComponent linkkiComponent = LINKKI_COMPONENT_ANNOTATION.findOn(annotation) .orElseThrow(LINKKI_COMPONENT_ANNOTATION .missingAnnotation(annotation, annotatedElement, ComponentAnnotationReader.class.getSimpleName() + "#isComponentDefinition(Annotation)")); @SuppressWarnings("unchecked") Class<ComponentDefinitionCreator<A>> creatorClass = (Class<ComponentDefinitionCreator<A>>)linkkiComponent .value(); return Classes.instantiate(creatorClass).create(annotation, annotatedElement); } private  ComponentAnnotationReader(); }
ComponentAnnotationReader { public static <A extends Annotation> LinkkiComponentDefinition getComponentDefinition( A annotation, AnnotatedElement annotatedElement) { LinkkiComponent linkkiComponent = LINKKI_COMPONENT_ANNOTATION.findOn(annotation) .orElseThrow(LINKKI_COMPONENT_ANNOTATION .missingAnnotation(annotation, annotatedElement, ComponentAnnotationReader.class.getSimpleName() + "#isComponentDefinition(Annotation)")); @SuppressWarnings("unchecked") Class<ComponentDefinitionCreator<A>> creatorClass = (Class<ComponentDefinitionCreator<A>>)linkkiComponent .value(); return Classes.instantiate(creatorClass).create(annotation, annotatedElement); } private  ComponentAnnotationReader(); static boolean isComponentDefinition(@CheckForNull Annotation annotation); static boolean isComponentDefinitionPresent(AnnotatedElement annotatedElement); static Stream<Method> getComponentDefinitionMethods(Class<?> pmoClass); static LinkkiComponentDefinition getComponentDefinition(
            A annotation,
            AnnotatedElement annotatedElement); static Optional<LinkkiComponentDefinition> findComponentDefinition(AnnotatedElement annotatedElement); static Annotation getComponentDefinitionAnnotation(AnnotatedElement annotatedElement, Object pmo); }
ComponentAnnotationReader { public static <A extends Annotation> LinkkiComponentDefinition getComponentDefinition( A annotation, AnnotatedElement annotatedElement) { LinkkiComponent linkkiComponent = LINKKI_COMPONENT_ANNOTATION.findOn(annotation) .orElseThrow(LINKKI_COMPONENT_ANNOTATION .missingAnnotation(annotation, annotatedElement, ComponentAnnotationReader.class.getSimpleName() + "#isComponentDefinition(Annotation)")); @SuppressWarnings("unchecked") Class<ComponentDefinitionCreator<A>> creatorClass = (Class<ComponentDefinitionCreator<A>>)linkkiComponent .value(); return Classes.instantiate(creatorClass).create(annotation, annotatedElement); } private  ComponentAnnotationReader(); static boolean isComponentDefinition(@CheckForNull Annotation annotation); static boolean isComponentDefinitionPresent(AnnotatedElement annotatedElement); static Stream<Method> getComponentDefinitionMethods(Class<?> pmoClass); static LinkkiComponentDefinition getComponentDefinition(
            A annotation,
            AnnotatedElement annotatedElement); static Optional<LinkkiComponentDefinition> findComponentDefinition(AnnotatedElement annotatedElement); static Annotation getComponentDefinitionAnnotation(AnnotatedElement annotatedElement, Object pmo); static final String COMPONENT_PROPERTY_SUFFIX; }