Class IdentityConverter<S extends T,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.IdentityConverter<S,T>
- Type Parameters:
S- the base type of source objects.T- the base type of converted objects.
- All Implemented Interfaces:
Serializable,Function<S,,T> ObjectConverter<S,T>
An object converter which returns the source unchanged.
Immutability and thread safety
This class is immutable and thus inherently thread-safe.- Since:
- 0.3
- Version:
- 0.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectConverter<T,S> The inverse converter specified at construction time, ornullif none.private static final longFor cross-version compatibility.Fields inherited from class org.apache.sis.internal.converter.ClassPair
sourceClass, targetClass -
Constructor Summary
ConstructorsConstructorDescriptionIdentityConverter(Class<S> sourceClass, Class<T> targetClass, ObjectConverter<T, S> inverse) Creates a new identity converter. -
Method Summary
Modifier and TypeMethodDescriptionReturns the given object unchanged.inverse()Returns the inverse converter, if any.Returns the properties of this converter.Methods inherited from class org.apache.sis.internal.converter.SystemConverter
bijective, equals, formatErrorMessage, getSourceClass, getTargetClass, readResolve, uniqueMethods 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:
-
inverse
The inverse converter specified at construction time, ornullif none.
-
-
Constructor Details
-
IdentityConverter
Creates a new identity converter.- Parameters:
sourceClass- the source class.targetClass- the target class.inverse- the inverse converter, ornullif none.
-
-
Method Details
-
properties
Returns the properties of this converter. This method returns a newEnumSetinstead of returning a constant, because creatingEnumSetis cheap and the standard JDK implementation has optimizations for bulk operations betweenEnumSetinstances. Those optimizations are lost (at least on JDK6) is we wrap theEnumSetin aCollections.unmodifiableSetview.- Returns:
- the manners in which source values are mapped to target values.
-
inverse
Returns the inverse converter, if any.- Specified by:
inversein interfaceObjectConverter<S extends T,T> - Overrides:
inversein classSystemConverter<S extends T,T> - Returns:
- a converter for converting instances of T back to instances of S.
- Throws:
UnsupportedOperationException- if this converter is not invertible.- See Also:
-
apply
Returns the given object unchanged.- Parameters:
source- the value to convert.- Returns:
- the given value unchanged.
-