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>
Enclosing class:
Converter<A,B>

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 Details

  • Constructor Details

    • IdentityConverter

      private IdentityConverter()
  • Method Details

    • doForward

      protected T doForward(T t)
      Description copied from class: Converter
      Returns a representation of a as an instance of type B. If a cannot be converted, an unchecked exception (such as IllegalArgumentException) should be thrown.
      Specified by:
      doForward in class Converter<T,T>
      Parameters:
      t - the instance to convert; will never be null
      Returns:
      the converted instance; must not be null
    • doBackward

      protected T doBackward(T t)
      Description copied from class: Converter
      Returns a representation of b as an instance of type A. If b cannot be converted, an unchecked exception (such as IllegalArgumentException) should be thrown.
      Specified by:
      doBackward in class Converter<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 converts this.convert(a) back to a value roughly equivalent to a.

      The returned converter is serializable if this converter is.

      Note: you should not override this method. It is non-final for legacy reasons.

      Overrides:
      reverse in class Converter<T,T>
    • 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.
      Overrides:
      doAndThen in class Converter<T,T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • readResolve

      private Object readResolve()