Polishing
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user