|
24 | 24 | import io.jooby.annotations.QueryParam; |
25 | 25 | import io.jooby.annotations.TRACE; |
26 | 26 |
|
| 27 | +import javax.annotation.Nonnull; |
27 | 28 | import javax.lang.model.element.AnnotationMirror; |
28 | 29 | import javax.lang.model.element.AnnotationValue; |
29 | 30 | import javax.lang.model.element.ExecutableElement; |
|
40 | 41 | import static java.util.Arrays.asList; |
41 | 42 | import static java.util.Collections.unmodifiableSet; |
42 | 43 |
|
| 44 | +/** |
| 45 | + * Annotation constants used by the APT. |
| 46 | + * |
| 47 | + * @since 2.1.0 |
| 48 | + */ |
43 | 49 | public interface Annotations { |
| 50 | + /** |
| 51 | + * HTTP method supported. |
| 52 | + */ |
44 | 53 | Set<String> HTTP_METHODS = unmodifiableSet(new LinkedHashSet<>(Arrays.asList( |
45 | 54 | GET.class.getName(), |
46 | 55 | javax.ws.rs.GET.class.getName(), |
@@ -68,46 +77,80 @@ public interface Annotations { |
68 | 77 | TRACE.class.getName() |
69 | 78 | ))); |
70 | 79 |
|
| 80 | + /** |
| 81 | + * Path parameters. |
| 82 | + */ |
71 | 83 | Set<String> PATH_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList(PathParam.class.getName()))); |
72 | 84 |
|
| 85 | + /** |
| 86 | + * Query parameters. |
| 87 | + */ |
73 | 88 | Set<String> QUERY_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList( |
74 | 89 | QueryParam.class.getName(), |
75 | 90 | javax.ws.rs.QueryParam.class.getName() |
76 | 91 | ))); |
77 | 92 |
|
| 93 | + /** |
| 94 | + * Cookie parameters. |
| 95 | + */ |
78 | 96 | Set<String> COOKIE_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList( |
79 | 97 | CookieParam.class.getName(), |
80 | 98 | javax.ws.rs.CookieParam.class.getName() |
81 | 99 | ))); |
82 | 100 |
|
| 101 | + /** |
| 102 | + * Header parameters. |
| 103 | + */ |
83 | 104 | Set<String> HEADER_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList( |
84 | 105 | HeaderParam.class.getName(), |
85 | 106 | javax.ws.rs.HeaderParam.class.getName() |
86 | 107 | ))); |
87 | 108 |
|
| 109 | + /** |
| 110 | + * Flash parameters. |
| 111 | + */ |
88 | 112 | Set<String> FLASH_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList(FlashParam.class.getName()))); |
89 | 113 |
|
| 114 | + /** |
| 115 | + * Form parameters. |
| 116 | + */ |
90 | 117 | Set<String> FORM_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList( |
91 | 118 | FormParam.class.getName(), |
92 | 119 | javax.ws.rs.FormParam.class.getName() |
93 | 120 | ))); |
94 | 121 |
|
| 122 | + /** |
| 123 | + * Produces parameters. |
| 124 | + */ |
95 | 125 | Set<String> PRODUCES_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList( |
96 | 126 | Produces.class.getName(), |
97 | 127 | javax.ws.rs.Produces.class.getName() |
98 | 128 | ))); |
99 | 129 |
|
| 130 | + /** |
| 131 | + * Consumes parameters. |
| 132 | + */ |
100 | 133 | Set<String> CONSUMES_PARAMS = unmodifiableSet(new LinkedHashSet<>(asList( |
101 | 134 | Consumes.class.getName(), |
102 | 135 | javax.ws.rs.Consumes.class.getName() |
103 | 136 | ))); |
104 | 137 |
|
| 138 | + /** |
| 139 | + * Path parameters. |
| 140 | + */ |
105 | 141 | Set<String> PATH = unmodifiableSet(new LinkedHashSet<>(asList( |
106 | 142 | Path.class.getName(), |
107 | 143 | javax.ws.rs.Path.class.getName() |
108 | 144 | ))); |
109 | 145 |
|
110 | | - static List<String> attribute(AnnotationMirror mirror, String name) { |
| 146 | + /** |
| 147 | + * Get an annotation value. |
| 148 | + * |
| 149 | + * @param mirror Annotation. |
| 150 | + * @param name Attribute name. |
| 151 | + * @return List of values. |
| 152 | + */ |
| 153 | + static @Nonnull List<String> attribute(@Nonnull AnnotationMirror mirror, @Nonnull String name) { |
111 | 154 | Function<Object, String> cleanValue = arg -> { |
112 | 155 | if (arg instanceof AnnotationValue) { |
113 | 156 | return ((AnnotationValue) arg).getValue().toString(); |
|
0 commit comments