Polish: Lambdas should be replaced with method references
This commit is contained in:
parent
d3a1d44864
commit
6ea0af3540
|
@ -744,8 +744,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
final FactoryBean<?> factory = (FactoryBean<?>) bean;
|
final FactoryBean<?> factory = (FactoryBean<?>) bean;
|
||||||
boolean isEagerInit;
|
boolean isEagerInit;
|
||||||
if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
|
if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
|
||||||
isEagerInit = AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
|
isEagerInit = AccessController.doPrivileged((PrivilegedAction<Boolean>)
|
||||||
((SmartFactoryBean<?>) factory).isEagerInit(),
|
((SmartFactoryBean<?>) factory)::isEagerInit,
|
||||||
getAccessControlContext());
|
getAccessControlContext());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -57,8 +57,8 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
||||||
protected Class<?> getTypeForFactoryBean(final FactoryBean<?> factoryBean) {
|
protected Class<?> getTypeForFactoryBean(final FactoryBean<?> factoryBean) {
|
||||||
try {
|
try {
|
||||||
if (System.getSecurityManager() != null) {
|
if (System.getSecurityManager() != null) {
|
||||||
return AccessController.doPrivileged((PrivilegedAction<Class<?>>) () ->
|
return AccessController.doPrivileged((PrivilegedAction<Class<?>>)
|
||||||
factoryBean.getObjectType(), getAccessControlContext());
|
factoryBean::getObjectType, getAccessControlContext());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return factoryBean.getObjectType();
|
return factoryBean.getObjectType();
|
||||||
|
@ -151,8 +151,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
||||||
if (System.getSecurityManager() != null) {
|
if (System.getSecurityManager() != null) {
|
||||||
AccessControlContext acc = getAccessControlContext();
|
AccessControlContext acc = getAccessControlContext();
|
||||||
try {
|
try {
|
||||||
object = AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
|
object = AccessController.doPrivileged((PrivilegedExceptionAction<Object>) factory::getObject, acc);
|
||||||
factory.getObject(), acc);
|
|
||||||
}
|
}
|
||||||
catch (PrivilegedActionException pae) {
|
catch (PrivilegedActionException pae) {
|
||||||
throw pae.getException();
|
throw pae.getException();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
||||||
try {
|
try {
|
||||||
if (System.getSecurityManager() != null) {
|
if (System.getSecurityManager() != null) {
|
||||||
constructorToUse = AccessController.doPrivileged(
|
constructorToUse = AccessController.doPrivileged(
|
||||||
(PrivilegedExceptionAction<Constructor<?>>) () -> clazz.getDeclaredConstructor());
|
(PrivilegedExceptionAction<Constructor<?>>) clazz::getDeclaredConstructor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
constructorToUse = clazz.getDeclaredConstructor();
|
constructorToUse = clazz.getDeclaredConstructor();
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import io.reactivex.BackpressureStrategy;
|
import io.reactivex.BackpressureStrategy;
|
||||||
|
import io.reactivex.Flowable;
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
@ -249,7 +250,7 @@ public class ReactiveAdapterRegistry {
|
||||||
registry.registerReactiveType(
|
registry.registerReactiveType(
|
||||||
multiValue(io.reactivex.Flowable.class, io.reactivex.Flowable::empty),
|
multiValue(io.reactivex.Flowable.class, io.reactivex.Flowable::empty),
|
||||||
source -> (io.reactivex.Flowable<?>) source,
|
source -> (io.reactivex.Flowable<?>) source,
|
||||||
source-> io.reactivex.Flowable.fromPublisher(source)
|
Flowable::fromPublisher
|
||||||
);
|
);
|
||||||
registry.registerReactiveType(
|
registry.registerReactiveType(
|
||||||
multiValue(io.reactivex.Observable.class, io.reactivex.Observable::empty),
|
multiValue(io.reactivex.Observable.class, io.reactivex.Observable::empty),
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ConvertingComparator<S, T> implements Comparator<S> {
|
||||||
* @return a new {@link ConvertingComparator} instance
|
* @return a new {@link ConvertingComparator} instance
|
||||||
*/
|
*/
|
||||||
public static <K, V> ConvertingComparator<Map.Entry<K, V>, K> mapEntryKeys(Comparator<K> comparator) {
|
public static <K, V> ConvertingComparator<Map.Entry<K, V>, K> mapEntryKeys(Comparator<K> comparator) {
|
||||||
return new ConvertingComparator<>(comparator, source -> source.getKey());
|
return new ConvertingComparator<>(comparator, Map.Entry::getKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +98,7 @@ public class ConvertingComparator<S, T> implements Comparator<S> {
|
||||||
* @return a new {@link ConvertingComparator} instance
|
* @return a new {@link ConvertingComparator} instance
|
||||||
*/
|
*/
|
||||||
public static <K, V> ConvertingComparator<Map.Entry<K, V>, V> mapEntryValues(Comparator<V> comparator) {
|
public static <K, V> ConvertingComparator<Map.Entry<K, V>, V> mapEntryValues(Comparator<V> comparator) {
|
||||||
return new ConvertingComparator<>(comparator, source -> source.getValue());
|
return new ConvertingComparator<>(comparator, Map.Entry::getValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class PropertyPlaceholderHelper {
|
||||||
*/
|
*/
|
||||||
public String replacePlaceholders(String value, final Properties properties) {
|
public String replacePlaceholders(String value, final Properties properties) {
|
||||||
Assert.notNull(properties, "'properties' must not be null");
|
Assert.notNull(properties, "'properties' must not be null");
|
||||||
return replacePlaceholders(value, placeholderName -> properties.getProperty(placeholderName));
|
return replacePlaceholders(value, properties::getProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -583,7 +583,7 @@ public abstract class ReflectionUtils {
|
||||||
*/
|
*/
|
||||||
public static Method[] getAllDeclaredMethods(Class<?> leafClass) {
|
public static Method[] getAllDeclaredMethods(Class<?> leafClass) {
|
||||||
final List<Method> methods = new ArrayList<>(32);
|
final List<Method> methods = new ArrayList<>(32);
|
||||||
doWithMethods(leafClass, method -> methods.add(method));
|
doWithMethods(leafClass, methods::add);
|
||||||
return methods.toArray(new Method[methods.size()]);
|
return methods.toArray(new Method[methods.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
|
||||||
public void setCorsConfigurations(@Nullable Map<String, CorsConfiguration> corsConfigurations) {
|
public void setCorsConfigurations(@Nullable Map<String, CorsConfiguration> corsConfigurations) {
|
||||||
this.corsConfigurations.clear();
|
this.corsConfigurations.clear();
|
||||||
if (corsConfigurations != null) {
|
if (corsConfigurations != null) {
|
||||||
corsConfigurations.forEach((path, config) -> registerCorsConfiguration(path, config));
|
corsConfigurations.forEach(this::registerCorsConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.web.reactive.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ public class WebFluxConfigurerComposite implements WebFluxConfigurer {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private <T> T createSingleBean(Function<WebFluxConfigurer, T> factory, Class<T> beanType) {
|
private <T> T createSingleBean(Function<WebFluxConfigurer, T> factory, Class<T> beanType) {
|
||||||
List<T> result = this.delegates.stream().map(factory).filter(t -> t != null).collect(Collectors.toList());
|
List<T> result = this.delegates.stream().map(factory).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue