@Override public AnnotationMetadata getAnnotationMetadata() { return argument.getAnnotationMetadata(); } }
@Override default AnnotationMetadata getAnnotationMetadata() { return getArgument().getAnnotationMetadata(); }
private Object resolveValue(ArgumentConversionContext<T> context, ConvertibleValues<?> values, String annotationValue) { Argument<T> argument = context.getArgument(); if (StringUtils.isEmpty(annotationValue)) { annotationValue = argument.getName(); } return values.get(annotationValue, context).orElseGet(() -> conversionService.convert(argument.getAnnotationMetadata().getValue(Bindable.class, DEFAULT_VALUE_MEMBER, String.class).orElse(null), context).orElse(null) ); }
@Override public <T> Optional<ArgumentBinder<T, HttpRequest<?>>> findArgumentBinder(Argument<T> argument, HttpRequest<?> source) { Optional<Class<? extends Annotation>> opt = argument.getAnnotationMetadata().getAnnotationTypeByStereotype(Bindable.class); if (opt.isPresent()) { Class<? extends Annotation> annotationType = opt.get(); RequestArgumentBinder<T> binder = findBinder(argument, annotationType); if (binder == null) { binder = byAnnotation.get(annotationType); } if (binder != null) { return Optional.of(binder); } } else { RequestArgumentBinder<T> binder = byType.get(argument.typeHashCode()); if (binder != null) { return Optional.of(binder); } else { binder = byType.get(Argument.of(argument.getType()).typeHashCode()); if (binder != null) { return Optional.of(binder); } } } return Optional.of(new ParameterAnnotationBinder<>(conversionService)); }
if (argument.getAnnotationMetadata().hasAnnotation(Nullable.class)) { boundArguments[i] = null; } else {
HttpMethod httpMethod = source.getMethod(); AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata(); boolean hasAnnotation = annotationMetadata.hasAnnotation(PathVariable.class); String parameterName = annotationMetadata.getValue(PathVariable.class, String.class).orElse(argument.getName());
if (argument.getAnnotationMetadata().hasAnnotation(Nullable.class)) { boundArguments[i] = null; } else {
); 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");
boolean permitsRequestBody = HttpMethod.permitsRequestBody(httpMethod); AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata(); boolean hasAnnotation = annotationMetadata.hasAnnotation(QueryValue.class); String parameterName = annotationMetadata.getValue(QueryValue.class, String.class).orElse(argument.getName());
for (Argument argument : arguments) { String argumentName = argument.getName(); AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata(); MutableArgumentValue<?> value = parameters.get(argumentName); Object definedValue = value.getValue(); final Object v = paramMap.get(argumentName); if (v != null) { paramMap.put(argumentName, conversionService.convert(v, ConversionContext.of(String.class).with(argument.getAnnotationMetadata()))); definedValue = argument.getAnnotationMetadata().getValue(Bindable.class, "defaultValue", String.class).orElse(null);
/** * @param argument An {@link Argument} * @return Whether the argument is a path parameter */ protected boolean isPathParameter(Argument argument) { AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata(); return annotationMetadata.hasDeclaredAnnotation(Selector.class); } }
/** * @param argument An {@link Argument} * @return Whether the argument is a path parameter */ protected boolean isPathParameter(Argument argument) { AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata(); return annotationMetadata.hasDeclaredAnnotation(Selector.class); } }
private Argument[] resolveRequiredArguments() { return Arrays.stream(getConstructor().getArguments()) .filter(arg -> { Optional<Class<? extends Annotation>> qualifierType = arg.getAnnotationMetadata().getAnnotationTypeByStereotype(Qualifier.class); return qualifierType.isPresent() && qualifierType.get() == Parameter.class; }) .toArray(Argument[]::new); } }
private Argument[] resolveRequiredArguments() { return Arrays.stream(getConstructor().getArguments()) .filter(arg -> { Optional<Class<? extends Annotation>> qualifierType = arg.getAnnotationMetadata().getAnnotationTypeByStereotype(Qualifier.class); return qualifierType.isPresent() && qualifierType.get() == Parameter.class; }) .toArray(Argument[]::new); } }
@SuppressWarnings("unchecked") @Override public Optional<Argument<?>> getBodyArgument() { Argument<?> arg = abstractRoute.bodyArgument; if (arg != null) { return Optional.of(arg); } String bodyArgument = abstractRoute.bodyArgumentName; if (bodyArgument != null) { return Optional.ofNullable(requiredInputs.get(bodyArgument)); } else { for (Argument argument : getArguments()) { if (argument.getAnnotationMetadata().hasAnnotation(Body.class)) { return Optional.of(argument); } } } return Optional.empty(); }
private String resolveInputName(Argument requiredArgument) { String inputName = requiredArgument.getAnnotationMetadata().getValue(Bindable.class, String.class).orElse(null); if (StringUtils.isEmpty(inputName)) { inputName = requiredArgument.getName(); } return inputName; } }
@Override public <T> Optional<ArgumentBinder<T, HttpRequest<?>>> findArgumentBinder(Argument<T> argument, HttpRequest<?> source) { Optional<Class<? extends Annotation>> opt = argument.getAnnotationMetadata().getAnnotationTypeByStereotype(Bindable.class); if (opt.isPresent()) { Class<? extends Annotation> annotationType = opt.get(); RequestArgumentBinder<T> binder = findBinder(argument, annotationType); if (binder == null) { binder = byAnnotation.get(annotationType); } if (binder != null) { return Optional.of(binder); } } else { RequestArgumentBinder<T> binder = byType.get(argument.typeHashCode()); if (binder != null) { return Optional.of(binder); } else { binder = byType.get(Argument.of(argument.getType()).typeHashCode()); if (binder != null) { return Optional.of(binder); } } } return Optional.of(new ParameterAnnotationBinder<>(conversionService)); }
private Qualifier resolveQualifier(BeanResolutionContext resolutionContext, Argument argument) { Qualifier qualifier = null; AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata(); Optional<Class<? extends Annotation>> qualifierType = annotationMetadata.getAnnotationTypeByStereotype(javax.inject.Qualifier.class); if (qualifierType.isPresent()) { qualifier = Qualifiers.byAnnotation( annotationMetadata, qualifierType.get() ); } if (qualifier == null) { Class<?>[] byType = annotationMetadata.hasDeclaredAnnotation(Type.class) ? annotationMetadata.getValue(Type.class, Class[].class).orElse(null) : null; if (byType != null) { qualifier = Qualifiers.byType(byType); } else { Optional<Qualifier> optional = resolutionContext.get(javax.inject.Qualifier.class.getName(), Map.class) .map(map -> (Qualifier) map.get(argument)); qualifier = optional.orElse(null); if (qualifier == null && isIterable() && argument.isAnnotationPresent(Parameter.class)) { qualifier = optional.orElseGet(() -> { final Optional<String> n = resolutionContext.get(Named.class.getName(), String.class); return n.map(Qualifiers::byName).orElse(null); }); } } } return qualifier; }
private String resolvePropertyValueName( BeanResolutionContext resolutionContext, AnnotationMetadata annotationMetadata, Argument argument, String valueAnnStr) { String valString; if (valueAnnStr != null) { valString = valueAnnStr; } else { valString = annotationMetadata.getValue(Property.class, "name", String.class) .orElseGet(() -> argument.getAnnotationMetadata().getValue(Property.class, "name", String.class) .orElseThrow(() -> new DependencyInjectionException( resolutionContext, argument, "Value resolution attempted but @Value annotation is missing" ) ) ); valString = substituteWildCards(resolutionContext, valString); } return valString; }
private String resolvePropertyValueName( BeanResolutionContext resolutionContext, AnnotationMetadata annotationMetadata, Argument argument, String valueAnnStr) { String valString; if (valueAnnStr != null) { valString = valueAnnStr; } else { valString = annotationMetadata.getValue(Property.class, "name", String.class) .orElseGet(() -> argument.getAnnotationMetadata().getValue(Property.class, "name", String.class) .orElseThrow(() -> new DependencyInjectionException( resolutionContext, argument, "Value resolution attempted but @Value annotation is missing" ) ) ); valString = substituteWildCards(resolutionContext, valString); } return valString; }