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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionFormats the specified key to a string representation.getType()Returns the type of the formatted object.static <T> Formatter<T>joining(Class<? extends T> type, String delimiter, Function<T, String[]> unwrapper, Function<String[], T> wrapper) static <T,V1, V2> Formatter<T> joining(Class<? extends T> type, String delimiter, Formatter<V1> formatter1, Formatter<V2> formatter2, Function<T, V1> unwrapper1, Function<T, V2> unwrapper2, BiFunction<V1, V2, T> wrapper) static <T> Formatter<T>of(T value) Parses the key from the specified string.default <U> Formatter<U>Returns a wrapped formatter.
-
Field Details
-
IDENTITY
-
-
Method Details
-
getType
Returns the type of the formatted object.- Returns:
- the type of the formatted object.
-
parse
Parses the key from the specified string.- Parameters:
value- a string representation of the key- Returns:
- the parsed key
-
format
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<? extends U> type, Function<U, T> unwrapper, Function<T, U> wrapper) Returns a wrapped formatter.- Type Parameters:
U- the wrapped type- Parameters:
type- the wrapped typeunwrapper- the unwrapper functionwrapper- the wrapper function- Returns:
- a wrapped formmater
-
of
-
joining
-
joining
-