Browse Source

Polishing

Issue: SPR-12483
pull/701/head
Juergen Hoeller 11 years ago
parent
commit
7635e7b7f2
  1. 5
      spring-core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java
  2. 7
      spring-core/src/main/java/org/springframework/core/convert/support/ArrayToObjectConverter.java
  3. 6
      spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.java
  4. 8
      spring-core/src/main/java/org/springframework/core/convert/support/ObjectToArrayConverter.java
  5. 7
      spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java

5
spring-core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java

@ -27,8 +27,9 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter; @@ -27,8 +27,9 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
import org.springframework.util.ObjectUtils;
/**
* Converts an Array to another Array. First adapts the source array to a List, then
* delegates to {@link CollectionToArrayConverter} to perform the target array conversion.
* Converts an array to another array. First adapts the source array to a List,
* then delegates to {@link CollectionToArrayConverter} to perform the target
* array conversion.
*
* @author Keith Donald
* @author Phillip Webb

7
spring-core/src/main/java/org/springframework/core/convert/support/ArrayToObjectConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -25,7 +25,8 @@ import org.springframework.core.convert.TypeDescriptor; @@ -25,7 +25,8 @@ import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.ConditionalGenericConverter;
/**
* Converts an Array to an Object by returning the first array element after converting it to the desired targetType.
* Converts an array to an Object by returning the first array element
* after converting it to the desired target type.
*
* @author Keith Donald
* @since 3.0
@ -34,10 +35,12 @@ final class ArrayToObjectConverter implements ConditionalGenericConverter { @@ -34,10 +35,12 @@ final class ArrayToObjectConverter implements ConditionalGenericConverter {
private final ConversionService conversionService;
public ArrayToObjectConverter(ConversionService conversionService) {
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(Object[].class, Object.class));

6
spring-core/src/main/java/org/springframework/core/convert/support/ArrayToStringConverter.java

@ -26,9 +26,9 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter; @@ -26,9 +26,9 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
import org.springframework.util.ObjectUtils;
/**
* Converts an Array to a comma-delimited String.
* This implementation first adapts the source Array to a List,
* then delegates to {@link CollectionToStringConverter} to perform the target String conversion.
* Converts an array to a comma-delimited String. First adapts the source array
* to a List, then delegates to {@link CollectionToStringConverter} to perform
* the target String conversion.
*
* @author Keith Donald
* @since 3.0

8
spring-core/src/main/java/org/springframework/core/convert/support/ObjectToArrayConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -25,8 +25,8 @@ import org.springframework.core.convert.TypeDescriptor; @@ -25,8 +25,8 @@ import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.ConditionalGenericConverter;
/**
* Converts an Object to a single-element Array containing the Object.
* Will convert the Object to the target Array's component type if necessary.
* Converts an Object to a single-element array containing the Object.
* Will convert the Object to the target array's component type if necessary.
*
* @author Keith Donald
* @since 3.0
@ -35,10 +35,12 @@ final class ObjectToArrayConverter implements ConditionalGenericConverter { @@ -35,10 +35,12 @@ final class ObjectToArrayConverter implements ConditionalGenericConverter {
private final ConversionService conversionService;
public ObjectToArrayConverter(ConversionService conversionService) {
this.conversionService = conversionService;
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(Object.class, Object[].class));

7
spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java

@ -20,12 +20,12 @@ import org.springframework.core.convert.converter.Converter; @@ -20,12 +20,12 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
/**
* Converts from a String to a java.lang.Enum by calling {@link Enum#valueOf(Class, String)}.
* Converts from a String to a {@link java.lang.Enum} by calling {@link Enum#valueOf(Class, String)}.
*
* @author Keith Donald
* @since 3.0
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
final class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
@Override
@ -35,7 +35,8 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu @@ -35,7 +35,8 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
enumType = enumType.getSuperclass();
}
if (enumType == null) {
throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum");
throw new IllegalArgumentException(
"The target type " + targetType.getName() + " does not refer to an enum");
}
return new StringToEnum(enumType);
}

Loading…
Cancel
Save