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;
|
||||
boolean isEagerInit;
|
||||
if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
|
||||
isEagerInit = AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
|
||||
((SmartFactoryBean<?>) factory).isEagerInit(),
|
||||
isEagerInit = AccessController.doPrivileged((PrivilegedAction<Boolean>)
|
||||
((SmartFactoryBean<?>) factory)::isEagerInit,
|
||||
getAccessControlContext());
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -57,8 +57,8 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
|||
protected Class<?> getTypeForFactoryBean(final FactoryBean<?> factoryBean) {
|
||||
try {
|
||||
if (System.getSecurityManager() != null) {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Class<?>>) () ->
|
||||
factoryBean.getObjectType(), getAccessControlContext());
|
||||
return AccessController.doPrivileged((PrivilegedAction<Class<?>>)
|
||||
factoryBean::getObjectType, getAccessControlContext());
|
||||
}
|
||||
else {
|
||||
return factoryBean.getObjectType();
|
||||
|
@ -151,8 +151,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
|||
if (System.getSecurityManager() != null) {
|
||||
AccessControlContext acc = getAccessControlContext();
|
||||
try {
|
||||
object = AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
|
||||
factory.getObject(), acc);
|
||||
object = AccessController.doPrivileged((PrivilegedExceptionAction<Object>) factory::getObject, acc);
|
||||
}
|
||||
catch (PrivilegedActionException pae) {
|
||||
throw pae.getException();
|
||||
|
|
|
@ -72,7 +72,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
|||
try {
|
||||
if (System.getSecurityManager() != null) {
|
||||
constructorToUse = AccessController.doPrivileged(
|
||||
(PrivilegedExceptionAction<Constructor<?>>) () -> clazz.getDeclaredConstructor());
|
||||
(PrivilegedExceptionAction<Constructor<?>>) clazz::getDeclaredConstructor);
|
||||
}
|
||||
else {
|
||||
constructorToUse = clazz.getDeclaredConstructor();
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
import java.util.function.Function;
|
||||
|
||||
import io.reactivex.BackpressureStrategy;
|
||||
import io.reactivex.Flowable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -249,7 +250,7 @@ public class ReactiveAdapterRegistry {
|
|||
registry.registerReactiveType(
|
||||
multiValue(io.reactivex.Flowable.class, io.reactivex.Flowable::empty),
|
||||
source -> (io.reactivex.Flowable<?>) source,
|
||||
source-> io.reactivex.Flowable.fromPublisher(source)
|
||||
Flowable::fromPublisher
|
||||
);
|
||||
registry.registerReactiveType(
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
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) {
|
||||
final List<Method> methods = new ArrayList<>(32);
|
||||
doWithMethods(leafClass, method -> methods.add(method));
|
||||
doWithMethods(leafClass, methods::add);
|
||||
return methods.toArray(new Method[methods.size()]);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
|
|||
public void setCorsConfigurations(@Nullable Map<String, CorsConfiguration> corsConfigurations) {
|
||||
this.corsConfigurations.clear();
|
||||
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.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -101,7 +102,7 @@ public class WebFluxConfigurerComposite implements WebFluxConfigurer {
|
|||
|
||||
@Nullable
|
||||
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()) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue