Spring cleaning: use diamond operator

This commit is contained in:
Sam Brannen
2024-02-23 11:52:17 +01:00
parent 233b59f144
commit 4339c8eac2
18 changed files with 25 additions and 25 deletions

View File

@@ -154,7 +154,7 @@ class CollectionFactoryTests {
@Test
void createApproximateCollectionFromEmptyHashSet() {
Collection<String> set = createApproximateCollection(new HashSet<String>(), 2);
Collection<String> set = createApproximateCollection(new HashSet<>(), 2);
assertThat(set).isEmpty();
}
@@ -180,7 +180,7 @@ class CollectionFactoryTests {
@Test
void createApproximateMapFromEmptyHashMap() {
Map<String, String> map = createApproximateMap(new HashMap<String, String>(), 2);
Map<String, String> map = createApproximateMap(new HashMap<>(), 2);
assertThat(map).isEmpty();
}
@@ -194,7 +194,7 @@ class CollectionFactoryTests {
@Test
void createApproximateMapFromEmptyEnumMap() {
Map<Color, String> colors = createApproximateMap(new EnumMap<Color, String>(Color.class), 2);
Map<Color, String> colors = createApproximateMap(new EnumMap<>(Color.class), 2);
assertThat(colors).isEmpty();
}

View File

@@ -170,7 +170,7 @@ class ResolvableTypeTests {
@Test
void forInstanceProviderNull() {
ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<String>(null));
ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<>(null));
assertThat(type.getType()).isEqualTo(MyGenericInterfaceType.class);
assertThat(type.resolve()).isEqualTo(MyGenericInterfaceType.class);
}

View File

@@ -485,7 +485,7 @@ class GenericConversionServiceTests {
void enumWithInterfaceToStringConversion() {
// SPR-9692
conversionService.addConverter(new EnumToStringConverter(conversionService));
conversionService.addConverter(new MyEnumInterfaceToStringConverter<MyEnum>());
conversionService.addConverter(new MyEnumInterfaceToStringConverter<>());
assertThat(conversionService.convert(MyEnum.A, String.class)).isEqualTo("1");
}

View File

@@ -423,9 +423,9 @@ class AnnotationMetadataTests {
assertThat(method.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")).isEqualTo("direct");
assertThat(method.getAnnotationAttributes(DirectAnnotation.class.getName()).get("myValue")).isEqualTo("direct");
List<Object> allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "meta")));
allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(List.of("direct")));
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(List.of("direct")));
assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isTrue();
@@ -465,9 +465,9 @@ class AnnotationMetadataTests {
assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")).isEqualTo("direct");
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "meta")));
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "")));
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "")));
assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additional")).isEqualTo("");
assertThat(((String[]) metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additionalArray"))).isEmpty();
}
@@ -498,7 +498,7 @@ class AnnotationMetadataTests {
assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")).isEqualTo("direct");
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<>(Arrays.asList("direct", "meta")));
}
}

View File

@@ -47,7 +47,7 @@ class CollectionUtilsTests {
void isEmpty() {
assertThat(CollectionUtils.isEmpty((Set<Object>) null)).isTrue();
assertThat(CollectionUtils.isEmpty((Map<String, String>) null)).isTrue();
assertThat(CollectionUtils.isEmpty(new HashMap<String, String>())).isTrue();
assertThat(CollectionUtils.isEmpty(new HashMap<>())).isTrue();
assertThat(CollectionUtils.isEmpty(new HashSet<>())).isTrue();
List<Object> list = new ArrayList<>();