Replace relevant code with lambda
See gh-1454
This commit is contained in:
@@ -87,12 +87,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, new Converter<Map.Entry<K, V>, K>() {
|
||||
@Override
|
||||
public K convert(Map.Entry<K, V> source) {
|
||||
return source.getKey();
|
||||
}
|
||||
});
|
||||
return new ConvertingComparator<>(comparator, source -> source.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,12 +97,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, new Converter<Map.Entry<K, V>, V>() {
|
||||
@Override
|
||||
public V convert(Map.Entry<K, V> source) {
|
||||
return source.getValue();
|
||||
}
|
||||
});
|
||||
return new ConvertingComparator<>(comparator, source -> source.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -226,12 +226,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||
}
|
||||
|
||||
private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) {
|
||||
return helper.replacePlaceholders(text, new PropertyPlaceholderHelper.PlaceholderResolver() {
|
||||
@Override
|
||||
public String resolvePlaceholder(String placeholderName) {
|
||||
return getPropertyAsRawString(placeholderName);
|
||||
}
|
||||
});
|
||||
return helper.replacePlaceholders(text, placeholderName -> getPropertyAsRawString(placeholderName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,12 +108,7 @@ public class PropertyPlaceholderHelper {
|
||||
*/
|
||||
public String replacePlaceholders(String value, final Properties properties) {
|
||||
Assert.notNull(properties, "'properties' must not be null");
|
||||
return replacePlaceholders(value, new PlaceholderResolver() {
|
||||
@Override
|
||||
public String resolvePlaceholder(String placeholderName) {
|
||||
return properties.getProperty(placeholderName);
|
||||
}
|
||||
});
|
||||
return replacePlaceholders(value, placeholderName -> properties.getProperty(placeholderName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,12 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public abstract class ReflectionUtils {
|
||||
|
||||
/**
|
||||
* Pre-built FieldFilter that matches all non-static, non-final fields.
|
||||
*/
|
||||
public static final FieldFilter COPYABLE_FIELDS =
|
||||
field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()));
|
||||
|
||||
/**
|
||||
* Naming prefix for CGLIB-renamed methods.
|
||||
* @see #isCglibRenamedMethod
|
||||
@@ -845,18 +851,6 @@ public abstract class ReflectionUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pre-built FieldFilter that matches all non-static, non-final fields.
|
||||
*/
|
||||
public static final FieldFilter COPYABLE_FIELDS = new FieldFilter() {
|
||||
|
||||
@Override
|
||||
public boolean matches(Field field) {
|
||||
return !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Pre-built MethodFilter that matches all non-bridge methods.
|
||||
*/
|
||||
|
||||
@@ -53,18 +53,14 @@ public class CompletableToListenableFutureAdapter<T> implements ListenableFuture
|
||||
*/
|
||||
public CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture) {
|
||||
this.completableFuture = completableFuture;
|
||||
this.completableFuture.handle(new BiFunction<T, Throwable, Object>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public Object apply(T result, @Nullable Throwable ex) {
|
||||
if (ex != null) {
|
||||
callbacks.failure(ex);
|
||||
}
|
||||
else {
|
||||
callbacks.success(result);
|
||||
}
|
||||
return null;
|
||||
this.completableFuture.handle((result, exception) -> {
|
||||
if (exception != null) {
|
||||
callbacks.failure(exception);
|
||||
}
|
||||
else {
|
||||
callbacks.success(result);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class SettableListenableFuture<T> implements ListenableFuture<T> {
|
||||
|
||||
private static final Callable<Object> DUMMY_CALLABLE = new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
throw new IllegalStateException("Should never be called");
|
||||
}
|
||||
private static final Callable<Object> DUMMY_CALLABLE = () -> {
|
||||
throw new IllegalStateException("Should never be called");
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user