Browse Source

Polishing

pull/25598/head
Juergen Hoeller 7 years ago
parent
commit
c28cadbafc
  1. 9
      spring-core/src/main/java/org/springframework/util/PatternMatchUtils.java
  2. 17
      spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
  3. 13
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

9
spring-core/src/main/java/org/springframework/util/PatternMatchUtils.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,20 +39,22 @@ public abstract class PatternMatchUtils {
if (pattern == null || str == null) { if (pattern == null || str == null) {
return false; return false;
} }
int firstIndex = pattern.indexOf('*'); int firstIndex = pattern.indexOf('*');
if (firstIndex == -1) { if (firstIndex == -1) {
return pattern.equals(str); return pattern.equals(str);
} }
if (firstIndex == 0) { if (firstIndex == 0) {
if (pattern.length() == 1) { if (pattern.length() == 1) {
return true; return true;
} }
int nextIndex = pattern.indexOf('*', firstIndex + 1); int nextIndex = pattern.indexOf('*', 1);
if (nextIndex == -1) { if (nextIndex == -1) {
return str.endsWith(pattern.substring(1)); return str.endsWith(pattern.substring(1));
} }
String part = pattern.substring(1, nextIndex); String part = pattern.substring(1, nextIndex);
if ("".equals(part)) { if (part.isEmpty()) {
return simpleMatch(pattern.substring(nextIndex), str); return simpleMatch(pattern.substring(nextIndex), str);
} }
int partIndex = str.indexOf(part); int partIndex = str.indexOf(part);
@ -64,6 +66,7 @@ public abstract class PatternMatchUtils {
} }
return false; return false;
} }
return (str.length() >= firstIndex && return (str.length() >= firstIndex &&
pattern.substring(0, firstIndex).equals(str.substring(0, firstIndex)) && pattern.substring(0, firstIndex).equals(str.substring(0, firstIndex)) &&
simpleMatch(pattern.substring(firstIndex), str.substring(firstIndex))); simpleMatch(pattern.substring(firstIndex), str.substring(firstIndex)));

17
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

@ -299,7 +299,7 @@ public class Jackson2ObjectMapperBuilder {
* @param mixinSource class (or interface) whose annotations are to be "added" * @param mixinSource class (or interface) whose annotations are to be "added"
* to target's annotations as value * to target's annotations as value
* @since 4.1.2 * @since 4.1.2
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class) * @see com.fasterxml.jackson.databind.ObjectMapper#addMixIn(Class, Class)
*/ */
public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) { public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) {
this.mixIns.put(target, mixinSource); this.mixIns.put(target, mixinSource);
@ -308,11 +308,11 @@ public class Jackson2ObjectMapperBuilder {
/** /**
* Add mix-in annotations to use for augmenting specified class or interface. * Add mix-in annotations to use for augmenting specified class or interface.
* @param mixIns Map of entries with target classes (or interface) whose annotations * @param mixIns a Map of entries with target classes (or interface) whose annotations
* to effectively override as key and mix-in classes (or interface) whose * to effectively override as key and mix-in classes (or interface) whose
* annotations are to be "added" to target's annotations as value. * annotations are to be "added" to target's annotations as value.
* @since 4.1.2 * @since 4.1.2
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class) * @see com.fasterxml.jackson.databind.ObjectMapper#addMixIn(Class, Class)
*/ */
public Jackson2ObjectMapperBuilder mixIns(Map<Class<?>, Class<?>> mixIns) { public Jackson2ObjectMapperBuilder mixIns(Map<Class<?>, Class<?>> mixIns) {
this.mixIns.putAll(mixIns); this.mixIns.putAll(mixIns);
@ -337,8 +337,8 @@ public class Jackson2ObjectMapperBuilder {
/** /**
* Configure a custom serializer for the given type. * Configure a custom serializer for the given type.
* @see #serializers(JsonSerializer...)
* @since 4.1.2 * @since 4.1.2
* @see #serializers(JsonSerializer...)
*/ */
public Jackson2ObjectMapperBuilder serializerByType(Class<?> type, JsonSerializer<?> serializer) { public Jackson2ObjectMapperBuilder serializerByType(Class<?> type, JsonSerializer<?> serializer) {
this.serializers.put(type, serializer); this.serializers.put(type, serializer);
@ -482,6 +482,8 @@ public class Jackson2ObjectMapperBuilder {
/** /**
* Specify one or more modules to be registered with the {@link ObjectMapper}. * Specify one or more modules to be registered with the {@link ObjectMapper}.
* Multiple invocations are not additive, the last one defines the modules to
* register.
* <p>Note: If this is set, no finding of modules is going to happen - not by * <p>Note: If this is set, no finding of modules is going to happen - not by
* Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}). * Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}).
* As a consequence, specifying an empty list here will suppress any kind of * As a consequence, specifying an empty list here will suppress any kind of
@ -497,6 +499,8 @@ public class Jackson2ObjectMapperBuilder {
/** /**
* Set a complete list of modules to be registered with the {@link ObjectMapper}. * Set a complete list of modules to be registered with the {@link ObjectMapper}.
* Multiple invocations are not additive, the last one defines the modules to
* register.
* <p>Note: If this is set, no finding of modules is going to happen - not by * <p>Note: If this is set, no finding of modules is going to happen - not by
* Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}). * Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}).
* As a consequence, specifying an empty list here will suppress any kind of * As a consequence, specifying an empty list here will suppress any kind of
@ -514,6 +518,8 @@ public class Jackson2ObjectMapperBuilder {
/** /**
* Specify one or more modules to be registered with the {@link ObjectMapper}. * Specify one or more modules to be registered with the {@link ObjectMapper}.
* Multiple invocations are not additive, the last one defines the modules
* to register.
* <p>Modules specified here will be registered after * <p>Modules specified here will be registered after
* Spring's autodetection of JSR-310 and Joda-Time, or Jackson's * Spring's autodetection of JSR-310 and Joda-Time, or Jackson's
* finding of modules (see {@link #findModulesViaServiceLoader}), * finding of modules (see {@link #findModulesViaServiceLoader}),
@ -530,7 +536,8 @@ public class Jackson2ObjectMapperBuilder {
/** /**
* Specify one or more modules by class to be registered with * Specify one or more modules by class to be registered with
* the {@link ObjectMapper}. * the {@link ObjectMapper}. Multiple invocations are not additive,
* the last one defines the modules to register.
* <p>Modules specified here will be registered after * <p>Modules specified here will be registered after
* Spring's autodetection of JSR-310 and Joda-Time, or Jackson's * Spring's autodetection of JSR-310 and Joda-Time, or Jackson's
* finding of modules (see {@link #findModulesViaServiceLoader}), * finding of modules (see {@link #findModulesViaServiceLoader}),

13
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -111,12 +111,9 @@ public class InvocableHandlerMethod extends HandlerMethod {
} }
/** /**
* Configure a reactive registry. This is needed for cases where the response * Configure a reactive adapter registry. This is needed for cases where the response is
* is fully handled within the controller in combination with an async void * fully handled within the controller in combination with an async void return value.
* return value. * <p>By default this is a {@link ReactiveAdapterRegistry} with default settings.
* <p>By default this is an instance of {@link ReactiveAdapterRegistry} with
* default settings.
* @param registry the registry to use
*/ */
public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) {
this.reactiveAdapterRegistry = registry; this.reactiveAdapterRegistry = registry;
@ -128,7 +125,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
* @param exchange the current exchange * @param exchange the current exchange
* @param bindingContext the binding context to use * @param bindingContext the binding context to use
* @param providedArgs optional list of argument values to match by type * @param providedArgs optional list of argument values to match by type
* @return a Mono with a {@link HandlerResult}. * @return a Mono with a {@link HandlerResult}
*/ */
public Mono<HandlerResult> invoke( public Mono<HandlerResult> invoke(
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) { ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {

Loading…
Cancel
Save