Use Stream.of().

This commit is contained in:
Gary Gregory 2021-07-01 14:55:58 -04:00
parent 5c6de5a7a0
commit 627a699bd0
2 changed files with 5 additions and 5 deletions

View File

@ -35,6 +35,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;
@ -745,13 +746,13 @@ public class MethodUtils {
Validate.notNull(cls, "cls");
Validate.notEmpty(methodName, "methodName");
final List<Method> methods = Arrays.stream(cls.getDeclaredMethods())
final List<Method> methods = Stream.of(cls.getDeclaredMethods())
.filter(method -> method.getName().equals(methodName))
.collect(toList());
ClassUtils.getAllSuperclasses(cls).stream()
.map(Class::getDeclaredMethods)
.flatMap(Arrays::stream)
.flatMap(Stream::of)
.filter(method -> method.getName().equals(methodName))
.forEach(methods::add);
@ -782,7 +783,7 @@ public class MethodUtils {
throw new IllegalStateException(
String.format("Found multiple candidates for method %s on class %s : %s",
methodName + Arrays.stream(parameterTypes).map(String::valueOf).collect(Collectors.joining(",", "(", ")")),
methodName + Stream.of(parameterTypes).map(String::valueOf).collect(Collectors.joining(",", "(", ")")),
cls.getName(),
bestCandidates.stream().map(Method::toString).collect(Collectors.joining(",", "[", "]")))
);

View File

@ -19,7 +19,6 @@ package org.apache.commons.lang3.time;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.stream.Stream;
@ -32,7 +31,7 @@ public class FastDatePrinterTimeZonesTest {
private static final String PATTERN = "h:mma z";
public static Stream<TimeZone> data() {
return Arrays.stream(TimeZone.getAvailableIDs()).map(TimeZone::getTimeZone);
return Stream.of(TimeZone.getAvailableIDs()).map(TimeZone::getTimeZone);
}
@ParameterizedTest