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, ornull
if none.private static final long
For 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, 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:
-
inverse
The inverse converter specified at construction time, ornull
if none.
-
-
Constructor Details
-
IdentityConverter
Creates a new identity converter.- Parameters:
sourceClass
- the source class.targetClass
- the target class.inverse
- the inverse converter, ornull
if none.
-
-
Method Details
-
properties
Returns the properties of this converter. This method returns a newEnumSet
instead of returning a constant, because creatingEnumSet
is cheap and the standard JDK implementation has optimizations for bulk operations betweenEnumSet
instances. Those optimizations are lost (at least on JDK6) is we wrap theEnumSet
in aCollections.unmodifiableSet
view.- Returns:
- the manners in which source values are mapped to target values.
-
inverse
Returns the inverse converter, if any.- Specified by:
inverse
in interfaceObjectConverter<S extends T,
T> - Overrides:
inverse
in 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.
-