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 TryFormatConversionCallback<T,TFormatType> extends Delegate
T
from one format to
another.Modifier and Type | Class and Description |
---|---|
static interface |
TryFormatConversionCallback.Function<T,TFormatType>
A functional interface for the containing delegate type.
|
Constructor and Description |
---|
TryFormatConversionCallback()
Creates a new instance of this delegate.
|
TryFormatConversionCallback(Class<?> targetClass,
String methodName,
Class<?>... methodParameterClasses)
Initializes a delegate that will invoke a static method on a class.
|
TryFormatConversionCallback(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 boolean |
invoke(T from,
TFormatType targetFormat,
T[] result)
A delegate to try converting a
T from one format to
another. |
static <T,TFormatType> |
of(TryFormatConversionCallback.Function<T,TFormatType> f)
Create a delegate for the given interface.
|
static <T,TFormatType> |
of(TryFormatConversionCallback.Function<T,TFormatType> f,
Class<?> targetClass,
String methodName,
Class<?>... methodParameterClasses)
Create a delegate for the given interface.
|
static <T,TFormatType> |
of(TryFormatConversionCallback.Function<T,TFormatType> f,
Object targetObject,
String methodName,
Class<?>... methodParameterClasses)
Create a delegate for the given interface.
|
public TryFormatConversionCallback()
public TryFormatConversionCallback(@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 TryFormatConversionCallback(@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 boolean invoke(T from, TFormatType targetFormat, @Nonnull T[] result)
T
from one format to
another.from
- The instance of T
to convert.targetFormat
- The TFormatType
to convert to.result
- On input, an array with one element. On return, the array is populated with
the resulting instance of T
equivalent to from
, in the new
TFormatType
targetFormat
.true
if from
could be converted to the
requested TFormatType
targetFormat
; otherwise false
.@Nonnull public static <T,TFormatType> TryFormatConversionCallback<T,TFormatType> of(@Nonnull TryFormatConversionCallback.Function<T,TFormatType> f)
f
- The function which will be invoked.@Nonnull public static <T,TFormatType> TryFormatConversionCallback<T,TFormatType> of(@Nonnull TryFormatConversionCallback.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> TryFormatConversionCallback<T,TFormatType> of(@Nonnull TryFormatConversionCallback.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.