public interface BiConvertor<S,T>
| Modifier and Type | Method and Description |
|---|---|
default boolean |
canToSource(Class<?> source,
Object target)
Whether the target can be converted to the specified source type
|
default boolean |
canToSource(Object target)
Whether the target can be converted to the source
|
default boolean |
canToTarget(Class<?> target,
Object source)
Whether the source can be converted to the specified target type
|
default boolean |
canToTarget(Object source)
Whether the source can be converted to the target
|
default <R> BiConvertor<S,R> |
compose(BiConvertor<T,R> that)
Combine S2T and T2R to S2R convertor
|
static <A,B> BiConvertor<A,B> |
of(Class<A> ca,
Class<B> cb,
Function<? super A,? extends B> a2b,
Function<? super B,? extends A> b2a)
Tool to construct a A2B anonymous convertor
|
default BiConvertor<T,S> |
reverseBiConvertor()
reverse the source and target
|
@NotNull Class<S> |
sourceType()
the source type
|
@NotNull Class<T> |
targetType()
the target type
|
S |
toSource(T target)
convert target to source
|
T |
toTarget(S source)
convert source to target
|
default S |
tryToSource(Class<?> source,
Object target)
Try to convert any target to source, first check `canToSource`, then try, return null if it can't
|
default S |
tryToSource(Object target)
Try to convert any target to source, first check `canToSource`, then try, return null if it can't
|
default T |
tryToTarget(Class<?> target,
Object source)
Try to convert any source to target, first check `canToTarget`, then try, return null if it can't
|
default T |
tryToTarget(Object source)
Try to convert any source to target, first check `canToTarget`, then try, return null if it can't
|
@Nullable @Contract(value="null->null;!null->!null") T toTarget(S source)
source - the sourceIllegalFormatConversionException - if unsupported@Nullable @Contract(value="null->null;!null->!null") S toSource(T target)
target - the targetIllegalFormatConversionException - if unsupported@Nullable default T tryToTarget(Object source)
source - any type of source@Nullable default S tryToSource(Object target)
target - any type of target@Nullable default T tryToTarget(Class<?> target, Object source)
target - target typesource - any source@Nullable default S tryToSource(Class<?> source, Object target)
source - source typetarget - any targetdefault boolean canToSource(Class<?> source, Object target)
source - the source typetarget - targetdefault boolean canToTarget(Class<?> target, Object source)
target - the target typesource - sourcedefault boolean canToSource(Object target)
default boolean canToTarget(Object source)
default BiConvertor<T,S> reverseBiConvertor()
default <R> BiConvertor<S,R> compose(BiConvertor<T,R> that)
R - return typethat - T2R convertorstatic <A,B> BiConvertor<A,B> of(Class<A> ca, Class<B> cb, Function<? super A,? extends B> a2b, Function<? super B,? extends A> b2a)
A - AB - Bca - class Acb - class Ba2b - a2b lambdab2a - b2a lambdaCopyright © 2024. All rights reserved.