T - the type of the input to the converterR - the type of the result of the converter@ParametersAreNonnullByDefault public interface Converter<T,R> extends Function<T,R>
Function that converts an object of type T to another of type R.
The reverse operation may be strict inverse, meaning that converter.revert(converter.convert(a)).equals(a)
always true.
Function| Modifier and Type | Method and Description |
|---|---|
default R |
apply(T t) |
static <T,U,R> Converter<T,R> |
compose(Converter<T,U> before,
Converter<U,R> after)
Returns a composed converter that first applies the
before function to its input, and then applies the
after function to the result. |
R |
convert(T t)
Returns a representation of
t as an instance of type R. |
static <T,R> Converter<T,R> |
from(Function<? super T,? extends R> convertFunc,
Function<? super R,? extends T> revertFunc)
Creates a converter based on separate forward and backward functions.
|
static <T> Converter<T,T> |
identity()
Creates a converter that always converts or reverses an object to itself.
|
default Converter<R,T> |
reverse()
Returns the reversed converter of this converter.
|
T |
revert(R r)
Returns a representation of
r as an instance of type T. |
@Nonnull static <T> Converter<T,T> identity()
@Nonnull static <T,R> Converter<T,R> from(Function<? super T,? extends R> convertFunc, Function<? super R,? extends T> revertFunc)
T - the type of the input to the converterR - the type of the result of the converterconvertFunc - the function used for convert(Object)revertFunc - the function used for revert(Object)@Nonnull static <T,U,R> Converter<T,R> compose(Converter<T,U> before, Converter<U,R> after)
before function to its input, and then applies the
after function to the result. This behavior is inverted when calling revert(Object).T - the type of input to the before converter, and to the composed functionU - the intermediate typeR - the type of output of the after converter, and of the composed functionbefore - the first converterafter - the second converterR convert(T t)
t as an instance of type R.t - the instance to convertT revert(R r)
r as an instance of type T.r - the instance to convertCopyright © 2017–2019 Atlanmod. All rights reserved.