T - The type of object that this delegate converts the format of.TFormatType - The class of the format object itself. This can be a base class.public abstract class FormatConversionCallback<T,TFormatType> extends Delegate
T from one format to another.| Modifier and Type | Class and Description |
|---|---|
static interface |
FormatConversionCallback.Function<T,TFormatType>
A functional interface for the containing delegate type.
|
| Constructor and Description |
|---|
FormatConversionCallback()
Creates a new instance of this delegate.
|
FormatConversionCallback(Class<?> targetClass,
String methodName,
Class<?>... methodParameterClasses)
Initializes a delegate that will invoke a static method on a class.
|
FormatConversionCallback(Object targetObject,
String methodName,
Class<?>... methodParameterClasses)
Initializes a delegate that will invoke an instance method on a class instance.
|
| Modifier and Type | Method and Description |
|---|---|
abstract T |
invoke(T from,
TFormatType targetFormat)
A delegate to convert a
T from one format to another. |
static <T,TFormatType> |
of(FormatConversionCallback.Function<T,TFormatType> f)
Create a delegate for the given interface.
|
static <T,TFormatType> |
of(FormatConversionCallback.Function<T,TFormatType> f,
Class<?> targetClass,
String methodName,
Class<?>... methodParameterClasses)
Create a delegate for the given interface.
|
static <T,TFormatType> |
of(FormatConversionCallback.Function<T,TFormatType> f,
Object targetObject,
String methodName,
Class<?>... methodParameterClasses)
Create a delegate for the given interface.
|
public FormatConversionCallback()
public FormatConversionCallback(@Nonnull Object targetObject, @Nonnull String methodName, @Nonnull Class<?>... methodParameterClasses)
targetObject - The class instance on which the delegate will invoke the method.methodName - The name of the instance method.methodParameterClasses - The type of the parameters of the instance method.public FormatConversionCallback(@Nonnull Class<?> targetClass, @Nonnull String methodName, @Nonnull Class<?>... methodParameterClasses)
targetClass - The class that defines the method.methodName - The name of the static method.methodParameterClasses - The type of the parameters of the static method.public abstract T invoke(T from, TFormatType targetFormat)
T from one format to another.from - The instance of T to convert.targetFormat - The TFormatType to convert to.T equivalent to from,
in the new TFormatType targetFormat.@Nonnull public static <T,TFormatType> FormatConversionCallback<T,TFormatType> of(@Nonnull FormatConversionCallback.Function<T,TFormatType> f)
f - The function which will be invoked.@Nonnull public static <T,TFormatType> FormatConversionCallback<T,TFormatType> of(@Nonnull FormatConversionCallback.Function<T,TFormatType> f, @Nonnull Object targetObject, @Nonnull String methodName, @Nonnull Class<?>... methodParameterClasses)
f - The function which will be invoked.targetObject - The class instance on which the delegate will invoke the method.methodName - The name of the instance method.methodParameterClasses - The type of the parameters of the instance method.@Nonnull public static <T,TFormatType> FormatConversionCallback<T,TFormatType> of(@Nonnull FormatConversionCallback.Function<T,TFormatType> f, @Nonnull Class<?> targetClass, @Nonnull String methodName, @Nonnull Class<?>... methodParameterClasses)
f - The function which will be invoked.targetClass - The class that defines the method.methodName - The name of the static method.methodParameterClasses - The type of the parameters of the static method.