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>
,java.io.Serializable
,java.util.function.Function<T,T>
private static final class Converter.IdentityConverter<T> extends Converter<T,T> implements java.io.Serializable
A converter that always converts or reverses an object to itself. Note that T is now a "pass-through type".
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Converter.IdentityConverter<?>
INSTANCE
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
IdentityConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) <S> Converter<T,S>
doAndThen(Converter<T,S> otherConverter)
Package-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
doForward(T t)
Returns a representation ofa
as an instance of typeB
.private java.lang.Object
readResolve()
Converter.IdentityConverter<T>
reverse()
Returns the reversed view of this converter, which convertsthis.convert(a)
back to a value roughly equivalent toa
.java.lang.String
toString()
-
Methods inherited from class com.google.common.base.Converter
andThen, apply, convert, convertAll, correctedDoBackward, correctedDoForward, equals, from, identity
-
-
-
-
Field Detail
-
INSTANCE
static final Converter.IdentityConverter<?> INSTANCE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
doForward
protected T doForward(T t)
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
protected T doBackward(T t)
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
public Converter.IdentityConverter<T> 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
<S> Converter<T,S> doAndThen(Converter<T,S> otherConverter)
Description copied from class:Converter
Package-private non-final implementation of andThen() so only we can override it.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
readResolve
private java.lang.Object readResolve()
-
-