Interface Formatter<T>

Type Parameters:
T - the formatted type
All Known Subinterfaces:
Formatter.Identity
All Known Implementing Classes:
Formatter.Provided

public interface Formatter<T>
Formats an objects into a string representation and back again.
Author:
Paul Ferraro
  • Field Details

  • Method Details

    • getTargetClass

      Class<T> getTargetClass()
      The implementation class of the target key of this format.
      Returns:
      an implementation class
    • parse

      T parse(String value)
      Parses the key from the specified string.
      Parameters:
      value - a string representation of the key
      Returns:
      the parsed key
    • format

      String format(T value)
      Formats the specified key to a string representation.
      Parameters:
      value - a key to format
      Returns:
      a string representation of the specified key.
    • wrap

      default <U> Formatter<U> wrap(Class<U> targetClass, Function<T,U> wrapper, Function<U,T> unwrapper)
      Returns a wrapped formatter.
      Type Parameters:
      U - the wrapped type
      Parameters:
      targetClass - the wrapped type
      wrapper - the wrapper function
      unwrapper - the unwrapper function
      Returns:
      a wrapped formmater
    • of

      static <T> Formatter<T> of(T value)
    • serialized

      static <T> Formatter<T> serialized(Class<T> targetClass, Serializer<T> serializer)