Class Converter.FunctionBasedConverter<A,​B>

  • All Implemented Interfaces:
    Function<A,​B>, java.io.Serializable, java.util.function.Function<A,​B>
    Enclosing class:
    Converter<A,​B>

    private static final class Converter.FunctionBasedConverter<A,​B>
    extends Converter<A,​B>
    implements java.io.Serializable
    • Field Detail

      • forwardFunction

        private final Function<? super A,​? extends B> forwardFunction
      • backwardFunction

        private final Function<? super B,​? extends A> backwardFunction
    • Constructor Detail

      • FunctionBasedConverter

        private FunctionBasedConverter​(Function<? super A,​? extends B> forwardFunction,
                                       Function<? super B,​? extends A> backwardFunction)
    • Method Detail

      • doForward

        protected B doForward​(A a)
        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<A,​B>
        Parameters:
        a - the instance to convert; will never be null
        Returns:
        the converted instance; must not be null
      • doBackward

        protected A doBackward​(B b)
        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<A,​B>
        Parameters:
        b - the instance to convert; will never be null
        Returns:
        the converted instance; must not be null
      • equals

        public boolean equals​(java.lang.Object object)
        Description copied from class: Converter
        Indicates whether another object is equal to this converter.

        Most implementations will have no reason to override the behavior of Object.equals(java.lang.Object). However, an implementation may also choose to return true whenever object is a Converter that it considers interchangeable with this one. "Interchangeable" typically means that Objects.equal(this.convert(a), that.convert(a)) is true for all a of type A (and similarly for reverse). Note that a false result from this method does not imply that the converters are known not to be interchangeable.

        Specified by:
        equals in interface Function<A,​B>
        Overrides:
        equals in class Converter<A,​B>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object