@Test void shouldCallResolveSafelyMethod() throws Exception { ObjectIdentifier identifier = new ObjectIdentifier(null, String.class, newDurationAnnotation(), newSizeAnnotation("0.52")); ResolutionContext context = new ResolutionContext(null, identifier); TypeSafeAnnotationHandlerTestImpl handler = new TypeSafeAnnotationHandlerTestImpl(); Resolution<?> resolution = handler.resolve(context); assertThat(InjectorTestHelper.unwrapFromSimpleResolution(resolution), equalTo("demo")); assertThat(handler.value, equalTo("0.52")); }
@Override public final Resolution<?> resolve(ResolutionContext context) throws Exception { final Class<T> type = getAnnotationType(); for (Annotation annotation : context.getIdentifier().getAnnotations()) { if (type.isInstance(annotation)) { return resolveValueSafely(context, type.cast(annotation)); } } return null; }
TypeSafeAnnotationHandler implements Handler { @Override public final Resolution<?> resolve(ResolutionContext context) throws Exception { final Class<T> type = getAnnotationType(); for (Annotation annotation : context.getIdentifier().getAnnotations()) { if (type.isInstance(annotation)) { return resolveValueSafely(context, type.cast(annotation)); } } return null; } }
TypeSafeAnnotationHandler implements Handler { @Override public final Resolution<?> resolve(ResolutionContext context) throws Exception { final Class<T> type = getAnnotationType(); for (Annotation annotation : context.getIdentifier().getAnnotations()) { if (type.isInstance(annotation)) { return resolveValueSafely(context, type.cast(annotation)); } } return null; }  }
TypeSafeAnnotationHandler implements Handler { @Override public final Resolution<?> resolve(ResolutionContext context) throws Exception { final Class<T> type = getAnnotationType(); for (Annotation annotation : context.getIdentifier().getAnnotations()) { if (type.isInstance(annotation)) { return resolveValueSafely(context, type.cast(annotation)); } } return null; }  @Override final Resolution<?> resolve(ResolutionContext context); }
TypeSafeAnnotationHandler implements Handler { @Override public final Resolution<?> resolve(ResolutionContext context) throws Exception { final Class<T> type = getAnnotationType(); for (Annotation annotation : context.getIdentifier().getAnnotations()) { if (type.isInstance(annotation)) { return resolveValueSafely(context, type.cast(annotation)); } } return null; }  @Override final Resolution<?> resolve(ResolutionContext context);  }