Interface Formatter<T>
- Type Parameters:
T- the formatted type
- All Known Subinterfaces:
Formatter.Identity
- All Known Implementing Classes:
AddressSerializer.JGroupsAddressFormatter, EmbeddedCacheManagerGroupMemberSerializer.AddressGroupMemberFormatter, Formatter.Provided, KeyFormatter, LocalEmbeddedCacheManagerGroupMemberFormatter, SessionAttributesKeyFormatter, SessionKeyFormatter, SessionMetaDataKeyFormatter, UserContextKeyFormatter, UserSessionsKeyFormatter
public interface Formatter<T>
Formats an objects into a string representation and back again.
- Author:
- Paul Ferraro
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA formatter specialization for string formatting.static classA formatter decorator. -
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) Creates a composite formatter from the specified formatters.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) Creates a composite formatter from the specified formatters.static <T> Formatter<T> of(T value) Creates a formatter whoseparse(String)always returns the specified value.Parses the key from the specified string.default <U> Formatter<U> Returns a wrapped formatter.
-
Field Details
-
IDENTITY
An identity formatter
-
-
Method Details
-
getType
-
parse
-
format
-
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
Creates a formatter whoseparse(String)always returns the specified value.- Type Parameters:
T- the formatted type- Parameters:
value- the fixed value- Returns:
- a formatter whose
parse(String)always returns the specified value.
-
joining
static <T,V1, Formatter<T> joiningV2> (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) Creates a composite formatter from the specified formatters.- Type Parameters:
T- the formatted typeV1- the former component formatterV2- the latter component formatter- Parameters:
type- the formatted typedelimiter- a delimiterformatter1- the former formatterformatter2- the latter formatterunwrapper1- the unwrapper of the former formatterunwrapper2- the unwrapper of the latter formatterwrapper- a wrapper of the component formatters- Returns:
- a composite formatter
-
joining
static <T> Formatter<T> joining(Class<? extends T> type, String delimiter, Function<T, String[]> unwrapper, Function<String[], T> wrapper) Creates a composite formatter from the specified formatters.- Type Parameters:
T- the formatted type- Parameters:
type- the formatted typedelimiter- a delimiterunwrapper- the parsing unwrapping functionwrapper- the formatter wrapping function- Returns:
- a composite formatter from the specified formatters.
-