|
22 | 22 |
|
23 | 23 | import java.lang.annotation.Annotation;
|
24 | 24 | import java.lang.reflect.Method;
|
25 |
| -import java.util.ArrayList; |
26 |
| -import java.util.Arrays; |
27 |
| -import java.util.Collection; |
28 |
| -import java.util.Collections; |
29 |
| -import java.util.HashMap; |
30 |
| -import java.util.Iterator; |
31 |
| -import java.util.List; |
32 |
| -import java.util.Map; |
33 |
| -import java.util.Objects; |
34 |
| -import java.util.Optional; |
| 25 | +import java.util.*; |
35 | 26 | import java.util.concurrent.ConcurrentHashMap;
|
36 | 27 | import java.util.function.BiFunction;
|
37 | 28 | import java.util.function.Function;
|
|
68 | 59 | */
|
69 | 60 | public class WebHandler {
|
70 | 61 |
|
71 |
| - private static final MappingDiscoverer DISCOVERER = CachingMappingDiscoverer |
72 |
| - .of(new AnnotationMappingDiscoverer(RequestMapping.class)); |
| 62 | + @SuppressWarnings("deprecation") // |
| 63 | + public static final MappingDiscoverer DISCOVERER = CachingMappingDiscoverer |
| 64 | + .of(new PropertyResolvingMappingDiscoverer(new AnnotationMappingDiscoverer(RequestMapping.class))); |
73 | 65 |
|
74 | 66 | private static final Map<AffordanceKey, List<Affordance>> AFFORDANCES_CACHE = new ConcurrentReferenceHashMap<>();
|
75 | 67 |
|
@@ -169,7 +161,7 @@ private static <T extends LinkBuilder> PreparedWebHandler<T> linkTo(Object invoc
|
169 | 161 | }
|
170 | 162 |
|
171 | 163 | List<Affordance> affordances = AFFORDANCES_CACHE.computeIfAbsent(
|
172 |
| - AffordanceKey.of(invocation.getTargetType(), invocation.getMethod(), components), |
| 164 | + new AffordanceKey(invocation.getTargetType(), invocation.getMethod(), components), |
173 | 165 | key -> SpringAffordanceBuilder.create(key.type, key.method, key.href.toUriString(), DISCOVERER));
|
174 | 166 |
|
175 | 167 | return creator.createBuilder(components, variables, affordances);
|
@@ -242,46 +234,49 @@ private static final class AffordanceKey {
|
242 | 234 | private final Method method;
|
243 | 235 | private final UriComponents href;
|
244 | 236 |
|
245 |
| - private AffordanceKey(Class<?> type, Method method, UriComponents href) { |
| 237 | + AffordanceKey(Class<?> type, Method method, UriComponents href) { |
246 | 238 |
|
247 | 239 | this.type = type;
|
248 | 240 | this.method = method;
|
249 | 241 | this.href = href;
|
250 | 242 | }
|
251 | 243 |
|
252 |
| - public static AffordanceKey of(Class<?> type, Method method, UriComponents href) { |
253 |
| - return new AffordanceKey(type, method, href); |
254 |
| - } |
255 |
| - |
256 |
| - public Class<?> getType() { |
257 |
| - return this.type; |
258 |
| - } |
259 |
| - |
260 |
| - public Method getMethod() { |
261 |
| - return this.method; |
262 |
| - } |
263 |
| - |
264 |
| - public UriComponents getHref() { |
265 |
| - return this.href; |
266 |
| - } |
267 |
| - |
| 244 | + /* |
| 245 | + * (non-Javadoc) |
| 246 | + * @see java.lang.Object#equals(java.lang.Object) |
| 247 | + */ |
268 | 248 | @Override
|
269 |
| - public boolean equals(Object o) { |
| 249 | + public boolean equals(@Nullable Object o) { |
270 | 250 |
|
271 |
| - if (this == o) |
| 251 | + if (this == o) { |
272 | 252 | return true;
|
273 |
| - if (!(o instanceof AffordanceKey)) |
| 253 | + } |
| 254 | + |
| 255 | + if (!(o instanceof AffordanceKey)) { |
274 | 256 | return false;
|
| 257 | + } |
| 258 | + |
275 | 259 | AffordanceKey that = (AffordanceKey) o;
|
276 |
| - return Objects.equals(this.type, that.type) && Objects.equals(this.method, that.method) |
| 260 | + |
| 261 | + return Objects.equals(this.type, that.type) // |
| 262 | + && Objects.equals(this.method, that.method) // |
277 | 263 | && Objects.equals(this.href, that.href);
|
278 | 264 | }
|
279 | 265 |
|
| 266 | + /* |
| 267 | + * (non-Javadoc) |
| 268 | + * @see java.lang.Object#hashCode() |
| 269 | + */ |
280 | 270 | @Override
|
281 | 271 | public int hashCode() {
|
282 | 272 | return Objects.hash(this.type, this.method, this.href);
|
283 | 273 | }
|
284 | 274 |
|
| 275 | + /* |
| 276 | + * (non-Javadoc) |
| 277 | + * @see java.lang.Object#toString() |
| 278 | + */ |
| 279 | + @Override |
285 | 280 | public String toString() {
|
286 | 281 | return "WebHandler.AffordanceKey(type=" + this.type + ", method=" + this.method + ", href=" + this.href + ")";
|
287 | 282 | }
|
|
0 commit comments