From 78690a24fb3c0f0f163a8344d8ebc94fb743d589 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 7 Mar 2016 18:01:54 +0100 Subject: [PATCH] Add headers & name attributes to composed @RequestMapping annotations Issue: SPR-13992 --- .../web/bind/annotation/DeleteMapping.java | 15 +++++++++++++-- .../web/bind/annotation/GetMapping.java | 17 ++++++++++++++--- .../web/bind/annotation/PatchMapping.java | 17 ++++++++++++++--- .../web/bind/annotation/PostMapping.java | 17 ++++++++++++++--- .../web/bind/annotation/PutMapping.java | 17 ++++++++++++++--- 5 files changed, 69 insertions(+), 14 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/DeleteMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/DeleteMapping.java index 1bfa31a867..b9e0ee913c 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/DeleteMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/DeleteMapping.java @@ -33,8 +33,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.DELETE; *

Specifically, {@code @DeleteMapping} is a composed annotation that * acts as a shortcut for {@code @RequestMapping(method = RequestMethod.DELETE)}. * Furthermore, this annotation does not support the - * {@link RequestMapping#method method}, {@link RequestMapping#name name}, - * {@link RequestMapping#headers headers}, {@link RequestMapping#consumes consumes}, + * {@link RequestMapping#method method}, {@link RequestMapping#consumes consumes}, * and {@link RequestMapping#produces produces} attributes of {@code @RequestMapping}. * * @author Sam Brannen @@ -51,6 +50,12 @@ import static org.springframework.web.bind.annotation.RequestMethod.DELETE; @RequestMapping(method = DELETE) public @interface DeleteMapping { + /** + * Alias for {@link RequestMapping#name}. + */ + @AliasFor(annotation = RequestMapping.class) + String name() default ""; + /** * Alias for {@link RequestMapping#value}. */ @@ -69,4 +74,10 @@ public @interface DeleteMapping { @AliasFor(annotation = RequestMapping.class) String[] params() default {}; + /** + * Alias for {@link RequestMapping#headers}. + */ + @AliasFor(annotation = RequestMapping.class) + String[] headers() default {}; + } diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/GetMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/GetMapping.java index 1b91143266..c6d127c9d5 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/GetMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/GetMapping.java @@ -33,9 +33,8 @@ import static org.springframework.web.bind.annotation.RequestMethod.GET; *

Specifically, {@code @GetMapping} is a composed annotation that * acts as a shortcut for {@code @RequestMapping(method = RequestMethod.GET)}. * Furthermore, this annotation does not support the - * {@link RequestMapping#method method}, {@link RequestMapping#name name}, - * {@link RequestMapping#headers headers}, and {@link RequestMapping#consumes - * consumes} attributes of {@code @RequestMapping}. + * {@link RequestMapping#method method} and {@link RequestMapping#consumes consumes} + * attributes of {@code @RequestMapping}. * * @author Sam Brannen * @since 4.3 @@ -51,6 +50,12 @@ import static org.springframework.web.bind.annotation.RequestMethod.GET; @RequestMapping(method = GET) public @interface GetMapping { + /** + * Alias for {@link RequestMapping#name}. + */ + @AliasFor(annotation = RequestMapping.class) + String name() default ""; + /** * Alias for {@link RequestMapping#value}. */ @@ -69,6 +74,12 @@ public @interface GetMapping { @AliasFor(annotation = RequestMapping.class) String[] params() default {}; + /** + * Alias for {@link RequestMapping#headers}. + */ + @AliasFor(annotation = RequestMapping.class) + String[] headers() default {}; + /** * Alias for {@link RequestMapping#produces}. */ diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/PatchMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/PatchMapping.java index 5235bc9d0e..7f371340de 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/PatchMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/PatchMapping.java @@ -33,9 +33,8 @@ import static org.springframework.web.bind.annotation.RequestMethod.PATCH; *

Specifically, {@code @PatchMapping} is a composed annotation that * acts as a shortcut for {@code @RequestMapping(method = RequestMethod.PATCH)}. * Furthermore, this annotation does not support the - * {@link RequestMapping#method method}, {@link RequestMapping#name name}, - * {@link RequestMapping#headers headers}, and {@link RequestMapping#produces - * produces} attributes of {@code @RequestMapping}. + * {@link RequestMapping#method method} and {@link RequestMapping#produces produces} + * attributes of {@code @RequestMapping}. * * @author Sam Brannen * @since 4.3 @@ -51,6 +50,12 @@ import static org.springframework.web.bind.annotation.RequestMethod.PATCH; @RequestMapping(method = PATCH) public @interface PatchMapping { + /** + * Alias for {@link RequestMapping#name}. + */ + @AliasFor(annotation = RequestMapping.class) + String name() default ""; + /** * Alias for {@link RequestMapping#value}. */ @@ -69,6 +74,12 @@ public @interface PatchMapping { @AliasFor(annotation = RequestMapping.class) String[] params() default {}; + /** + * Alias for {@link RequestMapping#headers}. + */ + @AliasFor(annotation = RequestMapping.class) + String[] headers() default {}; + /** * Alias for {@link RequestMapping#consumes}. */ diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/PostMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/PostMapping.java index 2b2db362bc..c15fdf2ff4 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/PostMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/PostMapping.java @@ -33,9 +33,8 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST; *

Specifically, {@code @PostMapping} is a composed annotation that * acts as a shortcut for {@code @RequestMapping(method = RequestMethod.POST)}. * Furthermore, this annotation does not support the - * {@link RequestMapping#method method}, {@link RequestMapping#name name}, - * {@link RequestMapping#headers headers}, and {@link RequestMapping#produces - * produces} attributes of {@code @RequestMapping}. + * {@link RequestMapping#method method} and {@link RequestMapping#produces produces} + * attributes of {@code @RequestMapping}. * * @author Sam Brannen * @since 4.3 @@ -51,6 +50,12 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST; @RequestMapping(method = POST) public @interface PostMapping { + /** + * Alias for {@link RequestMapping#name}. + */ + @AliasFor(annotation = RequestMapping.class) + String name() default ""; + /** * Alias for {@link RequestMapping#value}. */ @@ -69,6 +74,12 @@ public @interface PostMapping { @AliasFor(annotation = RequestMapping.class) String[] params() default {}; + /** + * Alias for {@link RequestMapping#headers}. + */ + @AliasFor(annotation = RequestMapping.class) + String[] headers() default {}; + /** * Alias for {@link RequestMapping#consumes}. */ diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/PutMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/PutMapping.java index dfd159810e..eaec190a53 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/PutMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/PutMapping.java @@ -33,9 +33,8 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT; *

Specifically, {@code @PutMapping} is a composed annotation that * acts as a shortcut for {@code @RequestMapping(method = RequestMethod.PUT)}. * Furthermore, this annotation does not support the - * {@link RequestMapping#method method}, {@link RequestMapping#name name}, - * {@link RequestMapping#headers headers}, and {@link RequestMapping#produces - * produces} attributes of {@code @RequestMapping}. + * {@link RequestMapping#method method} and {@link RequestMapping#produces produces} + * attributes of {@code @RequestMapping}. * * @author Sam Brannen * @since 4.3 @@ -51,6 +50,12 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT; @RequestMapping(method = PUT) public @interface PutMapping { + /** + * Alias for {@link RequestMapping#name}. + */ + @AliasFor(annotation = RequestMapping.class) + String name() default ""; + /** * Alias for {@link RequestMapping#value}. */ @@ -69,6 +74,12 @@ public @interface PutMapping { @AliasFor(annotation = RequestMapping.class) String[] params() default {}; + /** + * Alias for {@link RequestMapping#headers}. + */ + @AliasFor(annotation = RequestMapping.class) + String[] headers() default {}; + /** * Alias for {@link RequestMapping#consumes}. */ -- GitLab