Introduce alias for 'value' attribute in @Header
This commit introduces 'name' as an alias for 'value' in @Header. Issue: SPR-11393
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,10 +22,13 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Annotation which indicates that a method parameter should be bound to a message header.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
* @since 4.0
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@@ -34,20 +37,30 @@ import java.lang.annotation.Target;
|
||||
public @interface Header {
|
||||
|
||||
/**
|
||||
* The name of the request header to bind to.
|
||||
* Alias for {@link #name}.
|
||||
*/
|
||||
@AliasFor(attribute = "name")
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* The name of the request header to bind to.
|
||||
* @since 4.2
|
||||
*/
|
||||
@AliasFor(attribute = "value")
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* Whether the header is required.
|
||||
* <p>Default is {@code true}, leading to an exception if the header missing. Switch this
|
||||
* to {@code false} if you prefer a {@code null} in case of the header missing.
|
||||
* <p>Default is {@code true}, leading to an exception if the header is
|
||||
* missing. Switch this to {@code false} if you prefer a {@code null}
|
||||
* value in case of a header missing.
|
||||
* @see #defaultValue
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
/**
|
||||
* The default value to use as a fallback. Supplying a default value implicitly
|
||||
* sets {@link #required} to {@code false}.
|
||||
* The default value to use as a fallback.
|
||||
* <p>Supplying a default value implicitly sets {@link #required} to {@code false}.
|
||||
*/
|
||||
String defaultValue() default ValueConstants.DEFAULT_NONE;
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class HeaderMethodArgumentResolver extends AbstractNamedValueMethodArgume
|
||||
private static class HeaderNamedValueInfo extends NamedValueInfo {
|
||||
|
||||
private HeaderNamedValueInfo(Header annotation) {
|
||||
super(annotation.value(), annotation.required(), annotation.defaultValue());
|
||||
super(annotation.name(), annotation.required(), annotation.defaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user