Interface Converter<V,U>

Type Parameters:
V - the source type
U - the target type
All Known Implementing Classes:
BiMap

public interface Converter<V,U>
A bidirectional conversion between two types.

Converters transform values in both directions: to(Object) converts from V to U, and from(Object) converts from U back to V. Unlike a mathematical bijection, conversions are not required to be strictly one-to-one.

Converters can be composed using andThen(Converter) or created from function pairs using Converters.of.

  • Method Summary

    Modifier and Type
    Method
    Description
    default <T> Converter<V,T>
    andThen(Converter<U,T> after)
    Returns a composed converter that first applies this converter, then applies the after converter.
    from(U value)
    Converts a value from the target type back to the source type.
    to(V value)
    Converts a value from the source type to the target type.
  • Method Details

    • to

      U to(V value)
      Converts a value from the source type to the target type.
      Parameters:
      value - the source value
      Returns:
      the converted target value
    • from

      V from(U value)
      Converts a value from the target type back to the source type.
      Parameters:
      value - the target value
      Returns:
      the converted source value
    • andThen

      default <T> Converter<V,T> andThen(Converter<U,T> after)
      Returns a composed converter that first applies this converter, then applies the after converter.
      Type Parameters:
      T - the target type of the resulting converter
      Parameters:
      after - the converter to apply after this one
      Returns:
      the composed converter