Package com.google.common.base
Class Converter.IdentityConverter<T>
java.lang.Object
com.google.common.base.Converter<T,T>
com.google.common.base.Converter.IdentityConverter<T>
- All Implemented Interfaces:
Function<T,
,T> Serializable
,Function<T,
T>
private static final class Converter.IdentityConverter<T>
extends Converter<T,T>
implements Serializable
A converter that always converts or reverses an object to itself. Note that T is now a
"pass-through type".
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Converter
<?, ?> private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPackage-private non-final implementation of andThen() so only we can override it.protected T
doBackward
(T t) Returns a representation ofb
as an instance of typeA
.protected T
Returns a representation ofa
as an instance of typeB
.private Object
reverse()
Returns the reversed view of this converter, which convertsthis.convert(a)
back to a value roughly equivalent toa
.toString()
Methods inherited from class com.google.common.base.Converter
andThen, apply, convert, convertAll, correctedDoBackward, correctedDoForward, equals, from, identity
-
Field Details
-
INSTANCE
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
IdentityConverter
private IdentityConverter()
-
-
Method Details
-
doForward
Description copied from class:Converter
Returns a representation ofa
as an instance of typeB
. Ifa
cannot be converted, an unchecked exception (such asIllegalArgumentException
) should be thrown. -
doBackward
Description copied from class:Converter
Returns a representation ofb
as an instance of typeA
. Ifb
cannot be converted, an unchecked exception (such asIllegalArgumentException
) should be thrown.- Specified by:
doBackward
in classConverter<T,
T> - Parameters:
t
- the instance to convert; will never be null- Returns:
- the converted instance; must not be null
-
reverse
Description copied from class:Converter
Returns the reversed view of this converter, which convertsthis.convert(a)
back to a value roughly equivalent toa
.The returned converter is serializable if
this
converter is.Note: you should not override this method. It is non-final for legacy reasons.
-
doAndThen
Description copied from class:Converter
Package-private non-final implementation of andThen() so only we can override it. -
toString
-
readResolve
-