Class ArrayConverter<S,T>
java.lang.Object
org.apache.sis.internal.converter.ClassPair<S,T>
org.apache.sis.internal.converter.SystemConverter<S,T>
org.apache.sis.internal.converter.ArrayConverter<S,T>
- All Implemented Interfaces:
Serializable
,Function<S,
,T> ObjectConverter<S,
T>
Handles conversions between arrays. This converter delegates element conversions to another converter given at
construction time. If the source and target types of this converter are
<S[]>
and <T[]>
, then
the source and target types of the element converter shall be <? super S>
and <? extends T>
respectively.
Immutability and thread safety
This class is immutable, and thus inherently thread-safe, if the converter given to the constructor is also immutable.- Since:
- 0.3
- Version:
- 0.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectConverter
<?, ?> The converter for array elements.private static final EnumSet
<FunctionProperty> The function properties which can be preserved by this converter.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.internal.converter.ClassPair
sourceClass, targetClass
-
Constructor Summary
ConstructorsConstructorDescriptionArrayConverter
(Class<S> sourceClass, Class<T> targetClass, ObjectConverter<?, ?> converter) Creates a new converter for the given source and target classes. -
Method Summary
Modifier and TypeMethodDescriptionConverts the given array.Infers the properties of this converter from the properties of the elements converter.Methods inherited from class org.apache.sis.internal.converter.SystemConverter
bijective, equals, formatErrorMessage, getSourceClass, getTargetClass, inverse, readResolve, unique
Methods inherited from class org.apache.sis.internal.converter.ClassPair
cast, hashCode, parentSource, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
PROPERTIES
The function properties which can be preserved by this converter. We do not preserve ordering because we don't have a universal criterion for array comparisons. For example, we don't know how the user wants to handle arrays of different lengths, or null elements. -
converter
The converter for array elements. The source and target types shall be compatible with the array component types of<S>
and<T>
(this constraint cannot be expressed by JDK 7 parameterized types).
-
-
Constructor Details
-
ArrayConverter
ArrayConverter(Class<S> sourceClass, Class<T> targetClass, ObjectConverter<?, ?> converter) Creates a new converter for the given source and target classes.- Parameters:
sourceClass
- the source class.targetClass
- the target class.converter
- the converter for array elements. The source and target types shall be the array component types of<S>
and<T>
.
-
-
Method Details
-
properties
Infers the properties of this converter from the properties of the elements converter.- Returns:
- the manners in which source values are mapped to target values. May be an empty set, but never null.
-
apply
Converts the given array.- Parameters:
source
- the object to convert, ornull
.- Returns:
- the converted object, or
null
. - Throws:
UnconvertibleObjectException
- if the given object is not an element of the function domain.
-