Java Code Examples for org.springframework.cloud.openfeign.AnnotatedParameterProcessor#processArgument()

The following examples show how to use org.springframework.cloud.openfeign.AnnotatedParameterProcessor#processArgument() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenFeignSpringMvcContract.java    From summerframework with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean processAnnotationsOnParameter(MethodMetadata data, Annotation[] annotations, int paramIndex) {
    boolean isHttpAnnotation = false;

    AnnotatedParameterProcessor.AnnotatedParameterContext context =
        new OpenFeignSpringMvcContract.SimpleAnnotatedParameterContext(data, paramIndex);
    Method method = this.processedMethods.get(data.configKey());
    for (Annotation parameterAnnotation : annotations) {
        AnnotatedParameterProcessor processor =
            this.annotatedArgumentProcessors.get(parameterAnnotation.annotationType());
        if (processor != null) {
            Annotation processParameterAnnotation;

            processParameterAnnotation =
                synthesizeWithMethodParameterNameAsFallbackValue(parameterAnnotation, method, paramIndex);
            isHttpAnnotation |= processor.processArgument(context, processParameterAnnotation, method);
        }
    }
    if (isHttpAnnotation && data.indexToExpander().get(paramIndex) == null
        && this.conversionService.canConvert(method.getParameterTypes()[paramIndex], String.class)) {
        data.indexToExpander().put(paramIndex, this.expander);
    }
    return isHttpAnnotation;
}
 
Example 2
Source File: SpringMvcContract.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean processAnnotationsOnParameter(MethodMetadata data,
		Annotation[] annotations, int paramIndex) {
	boolean isHttpAnnotation = false;

	AnnotatedParameterProcessor.AnnotatedParameterContext context = new SimpleAnnotatedParameterContext(
			data, paramIndex);
	Method method = this.processedMethods.get(data.configKey());
	for (Annotation parameterAnnotation : annotations) {
		AnnotatedParameterProcessor processor = this.annotatedArgumentProcessors
				.get(parameterAnnotation.annotationType());
		if (processor != null) {
			Annotation processParameterAnnotation;
			// synthesize, handling @AliasFor, while falling back to parameter name on
			// missing String #value():
			processParameterAnnotation = synthesizeWithMethodParameterNameAsFallbackValue(
					parameterAnnotation, method, paramIndex);
			isHttpAnnotation |= processor.processArgument(context,
					processParameterAnnotation, method);
		}
	}

	if (!isMultipartFormData(data) && isHttpAnnotation
			&& data.indexToExpander().get(paramIndex) == null) {
		TypeDescriptor typeDescriptor = createTypeDescriptor(method, paramIndex);
		if (this.conversionService.canConvert(typeDescriptor,
				STRING_TYPE_DESCRIPTOR)) {
			Param.Expander expander = this.convertingExpanderFactory
					.getExpander(typeDescriptor);
			if (expander != null) {
				data.indexToExpander().put(paramIndex, expander);
			}
		}
	}
	return isHttpAnnotation;
}
 
Example 3
Source File: VenusSpringMvcContract.java    From venus-cloud-feign with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean processAnnotationsOnParameter(MethodMetadata data,
                                                Annotation[] annotations, int paramIndex) {
    boolean isHttpAnnotation = false;

    AnnotatedParameterProcessor.AnnotatedParameterContext context = new VenusSpringMvcContract.SimpleAnnotatedParameterContext(
            data, paramIndex);
    Method method = this.processedMethods.get(data.configKey());
    for (Annotation parameterAnnotation : annotations) {
        AnnotatedParameterProcessor processor = this.annotatedArgumentProcessors
                .get(parameterAnnotation.annotationType());
        if (processor != null) {
            Annotation processParameterAnnotation;
            // synthesize, handling @AliasFor, while falling back to parameter name on
            // missing String #value():
            processParameterAnnotation = synthesizeWithMethodParameterNameAsFallbackValue(
                    parameterAnnotation, method, paramIndex);
            isHttpAnnotation |= processor.processArgument(context,
                    processParameterAnnotation, method);
        }
    }
    if (isHttpAnnotation && data.indexToExpander().get(paramIndex) == null
            && this.conversionService.canConvert(
            method.getParameterTypes()[paramIndex], String.class)) {
        data.indexToExpander().put(paramIndex, this.expander);
    }
    return isHttpAnnotation;
}