@Override default @Nonnull <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(@Nonnull String annotation) { return getAnnotationMetadata().findAnnotation(annotation); }
@Override default @Nonnull <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(@Nonnull Class<T> annotationClass) { return getAnnotationMetadata().findAnnotation(annotationClass); }
@Override default <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(String annotation) { return getAnnotationMetadata().findAnnotation(annotation); }
@Override default <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(Class<T> annotationClass) { return getAnnotationMetadata().findAnnotation(annotationClass); }
@Override default @Nonnull <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(@Nonnull String annotation) { return getAnnotationMetadata().findAnnotation(annotation); }
/** * Returns whether the value of the given member is present. * * @param annotation The annotation class * @param member The annotation member * @return True if the value is true */ default boolean isPresent(@Nonnull String annotation, @Nonnull String member) { ArgumentUtils.requireNonNull("annotation", annotation); ArgumentUtils.requireNonNull("member", member); return findAnnotation(annotation).map(av -> av.contains(member)).orElse(false); }
/** * Get all of the values for the given annotation. * * @param annotationClass The annotation name * @param <T> The annotation type * @return The {@link AnnotationValue} */ @Override default @Nonnull <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(@Nonnull Class<T> annotationClass) { ArgumentUtils.requireNonNull("annotationClass", annotationClass); Repeatable repeatable = annotationClass.getAnnotation(Repeatable.class); if (repeatable != null) { List<AnnotationValue<T>> values = getAnnotationValuesByType(annotationClass); if (!values.isEmpty()) { return Optional.of(values.iterator().next()); } else { return Optional.empty(); } } else { return this.findAnnotation(annotationClass.getName()); } }
/** * Get the value of the given annotation member. * * @param annotation The annotation class * @param member The annotation member * @param requiredType The required type * @param <T> The value * @return An {@link Optional} of the value */ default @Nonnull <T> Optional<T> getValue(@Nonnull String annotation, @Nonnull String member, @Nonnull Argument<T> requiredType) { ArgumentUtils.requireNonNull("annotation", annotation); ArgumentUtils.requireNonNull("member", member); ArgumentUtils.requireNonNull("requiredType", requiredType); Optional<T> value = findAnnotation(annotation).flatMap(av -> av.get(member, requiredType)); if (!value.isPresent()) { if (hasStereotype(annotation)) { return getDefaultValue(annotation, member, requiredType); } } return value; }
Optional<? extends AnnotationValue<? extends Annotation>> values = findAnnotation(annotation); Optional<T> value = values.flatMap(av -> av.get(member, requiredType)); if (!value.isPresent()) {
continue; Optional<AnnotationValue<Filter>> filterOpt = annotationMetadataResolver.resolveMetadata(filter).findAnnotation(Filter.class); if (filterOpt.isPresent()) { AnnotationValue<Filter> filterAnn = filterOpt.get();
); Argument argument = segment.getArgument(); AnnotationValue<Client> annotation = argument.getAnnotationMetadata().findAnnotation(Client.class).orElse(null); if (annotation == null) { throw new DependencyInjectionException(resolutionContext, argument, "ClientScope called for injection point that is not annotated with @Client");
@Override public RetryState build() { AnnotationValue<Retryable> retry = annotationMetadata.findAnnotation(Retryable.class) .orElseThrow(() -> new IllegalStateException("Missing @Retryable annotation")); int attempts = retry.get(ATTEMPTS, Integer.class).orElse(DEFAULT_RETRY_ATTEMPTS); Duration delay = retry.get(DELAY, Duration.class).orElse(Duration.ofSeconds(1)); Set<Class<? extends Throwable>> includes = resolveIncludes(retry, INCLUDES); Set<Class<? extends Throwable>> excludes = resolveIncludes(retry, EXCLUDES); return new SimpleRetry( attempts, retry.get(MULTIPLIER, Double.class).orElse(0d), delay, retry.get(MAX_DELAY, Duration.class).orElse(null), includes, excludes ); }
continue; Optional<AnnotationValue<Filter>> filterOpt = annotationMetadataResolver.resolveMetadata(filter).findAnnotation(Filter.class); if (filterOpt.isPresent()) { AnnotationValue<Filter> filterAnn = filterOpt.get();
continue; Optional<AnnotationValue<Filter>> filterOpt = annotationMetadataResolver.resolveMetadata(filter).findAnnotation(Filter.class); if (filterOpt.isPresent()) { AnnotationValue<Filter> filterAnn = filterOpt.get();
); Argument argument = segment.getArgument(); AnnotationValue<Client> annotation = argument.getAnnotationMetadata().findAnnotation(Client.class).orElse(null); if (annotation == null) { throw new DependencyInjectionException(resolutionContext, argument, "ClientScope called for injection point that is not annotated with @Client");
); Argument argument = segment.getArgument(); AnnotationValue<Client> annotation = argument.getAnnotationMetadata().findAnnotation(Client.class).orElse(null); if (annotation == null) { throw new DependencyInjectionException(resolutionContext, argument, "ClientScope called for injection point that is not annotated with @Client");