Browse Source

Store reversedMetaDistance Comparator in static field

pull/31076/head
Sam Brannen 2 years ago
parent
commit
285c92bb03
  1. 9
      spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java

9
spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java

@ -79,6 +79,9 @@ public abstract class TestPropertySourceUtils { @@ -79,6 +79,9 @@ public abstract class TestPropertySourceUtils {
private static final PropertySourceFactory defaultPropertySourceFactory = new DefaultPropertySourceFactory();
private static Comparator<MergedAnnotation<? extends Annotation>> reversedMetaDistance =
Comparator.<MergedAnnotation<? extends Annotation>> comparingInt(MergedAnnotation::getDistance).reversed();
private static final Log logger = LogFactory.getLog(TestPropertySourceUtils.class);
@ -426,7 +429,7 @@ public abstract class TestPropertySourceUtils { @@ -426,7 +429,7 @@ public abstract class TestPropertySourceUtils {
MergedAnnotations.from(clazz, SearchStrategy.DIRECT)
.stream(annotationType)
.sorted(highMetaDistancesFirst())
.sorted(reversedMetaDistance)
.forEach(annotation -> listOfLists.get(aggregateIndex[0]).add(0, annotation));
aggregateIndex[0]++;
@ -448,10 +451,6 @@ public abstract class TestPropertySourceUtils { @@ -448,10 +451,6 @@ public abstract class TestPropertySourceUtils {
}
}
private static <A extends Annotation> Comparator<MergedAnnotation<A>> highMetaDistancesFirst() {
return Comparator.<MergedAnnotation<A>> comparingInt(MergedAnnotation::getDistance).reversed();
}
/**
* Extension of {@link Properties} that mimics a {@code SequencedMap} by
* tracking all added properties in the supplied {@link LinkedHashMap}.

Loading…
Cancel
Save