Polishing

This commit is contained in:
Juergen Hoeller
2023-07-14 12:16:37 +02:00
parent bddd3feb83
commit 75f5dac16b
6 changed files with 28 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,8 +205,7 @@ public class GenericConversionService implements ConfigurableConversionService {
* @param targetType the target type
* @return the converted value
* @throws ConversionException if a conversion exception occurred
* @throws IllegalArgumentException if targetType is {@code null},
* or sourceType is {@code null} but source is not {@code null}
* @throws IllegalArgumentException if targetType is {@code null}
*/
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor targetType) {

View File

@@ -659,7 +659,7 @@ class DefaultConversionServiceTests {
foo.add("2");
foo.add("3");
@SuppressWarnings("unchecked")
List<Integer> bar = (List<Integer>) conversionService.convert(foo, TypeDescriptor.forObject(foo),
List<Integer> bar = (List<Integer>) conversionService.convert(foo,
new TypeDescriptor(getClass().getField("genericList")));
assertThat(bar).containsExactly(1, 2, 3);
}

View File

@@ -193,7 +193,7 @@ class CollectionToCollectionConverterTests {
@Test
void listToCollectionNoCopyRequired() throws NoSuchFieldException {
List<?> input = new ArrayList<>(Arrays.asList("foo", "bar"));
assertThat(conversionService.convert(input, TypeDescriptor.forObject(input),
assertThat(conversionService.convert(input,
new TypeDescriptor(getClass().getField("wildcardCollection")))).isSameAs(input);
}
@@ -253,7 +253,7 @@ class CollectionToCollectionConverterTests {
List<String> list = new ArrayList<>();
list.add("A");
list.add("C");
assertThat(conversionService.convert(list, TypeDescriptor.forObject(list), new TypeDescriptor(getClass().getField("enumSet")))).isEqualTo(EnumSet.of(MyEnum.A, MyEnum.C));
assertThat(conversionService.convert(list, new TypeDescriptor(getClass().getField("enumSet")))).isEqualTo(EnumSet.of(MyEnum.A, MyEnum.C));
}

View File

@@ -302,7 +302,7 @@ class GenericConversionServiceTests {
void wildcardMap() throws Exception {
Map<String, String> input = new LinkedHashMap<>();
input.put("key", "value");
Object converted = conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardMap")));
Object converted = conversionService.convert(input, new TypeDescriptor(getClass().getField("wildcardMap")));
assertThat(converted).isEqualTo(input);
}