Package org.atlanmod.commons.function
Interface BiConverter<T,U,R>
-
- Type Parameters:
T- the type of the first argument to the converterU- the type of the second argument to the converterR- the type of the result of the converter
- All Superinterfaces:
BiFunction<T,U,R>
@ParametersAreNonnullByDefault public interface BiConverter<T,U,R> extends BiFunction<T,U,R>
A specializedBiFunctionthat converts an object of typeTto another of typeR, by using an object of typeU.The reverse operation may be strict inverse, meaning that
converter.revert(converter.convert(a, c), c).equals(a)alwaystrue.- See Also:
BiFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Rapply(T t, U u)Rconvert(T t, U u)Returns a representation oftas an instance of typeR, by using an object of typeU.static <T,U,R>
BiConverter<T,U,R>from(BiFunction<? super T,? super U,? extends R> convertFunc, BiFunction<? super R,? super U,? extends T> revertFunc)Creates a bi-converter based on separate forward and backward functions.static <T,U>
BiConverter<T,U,T>identity()Creates a bi-converter that always converts or reverses an object to itself.default BiConverter<R,U,T>reverse()Returns the reversed converter of this converter.Trevert(R r, U u)Returns a representation ofras an instance of typeT, by using an object of typeU.-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
identity
@Nonnull static <T,U> BiConverter<T,U,T> identity()
Creates a bi-converter that always converts or reverses an object to itself.- Type Parameters:
T- the type of the converted instance and the result- Returns:
- a new converter
-
from
@Nonnull static <T,U,R> BiConverter<T,U,R> from(BiFunction<? super T,? super U,? extends R> convertFunc, BiFunction<? super R,? super U,? extends T> revertFunc)
Creates a bi-converter based on separate forward and backward functions.- Type Parameters:
T- the type of the first argument to the converterU- the type of the second argument to the converterR- the type of the result of the converter- Parameters:
convertFunc- the function used forconvert(Object, Object)revertFunc- the function used forrevert(Object, Object)- Returns:
- a new converter
-
convert
R convert(T t, U u)
Returns a representation oftas an instance of typeR, by using an object of typeU.- Parameters:
t- the instance to convertu- the helper instance- Returns:
- the converted instance
-
revert
T revert(R r, U u)
Returns a representation ofras an instance of typeT, by using an object of typeU.- Parameters:
r- the instance to convertu- the helper instance- Returns:
- the converted instance
-
reverse
@Nonnull default BiConverter<R,U,T> reverse()
Returns the reversed converter of this converter.- Returns:
- the reversed converter
-
-