I
- The object type resulting from conversions of values of type O.O
- The object type resulting from conversions of values of type I.Conversion<I,O>
ObjectConversion
, ToStringConversion
public abstract class NullConversion<I,O> extends java.lang.Object implements Conversion<I,O>
Extending classes must implement a proper String to T conversion in ObjectConversion.fromString(String)
This abstract class provides default results for conversions when the input is null.
Constructor | Description |
---|---|
NullConversion() |
Creates a Conversion from an object to another object of a different type, with default values to return when the input is null.
|
NullConversion(O valueOnNullInput,
I valueOnNullOutput) |
Creates a Conversion from an object to another object of a different type, with default values to return when the input is null.
|
Modifier and Type | Method | Description |
---|---|---|
O |
execute(I input) |
Converts the given instance of type I to an instance of O
|
protected abstract O |
fromInput(I input) |
Creates an instance of O from a I object
|
O |
getValueOnNullInput() |
returns a default value of type O to be returned when the input of type I is null.
|
I |
getValueOnNullOutput() |
returns default instance of I to be returned when an input of type O is null.
|
I |
revert(O input) |
Converts a value of type O back to a value of type I
|
void |
setValueOnNullInput(O valueOnNullInput) |
defines the default value of type O which should be returned when
execute(Object) is invoked with a null I.. |
void |
setValueOnNullOutput(I valueOnNullOutput) |
defines the default value of type I which should be returned when
revert(Object) is invoked with a null O. |
protected abstract I |
undo(O input) |
Converts a value of type O back to I.
|
public NullConversion()
public NullConversion(O valueOnNullInput, I valueOnNullOutput)
valueOnNullInput
- default value of type O to be returned when the input object I is null. Used when execute(Object)
is invoked.valueOnNullOutput
- default value of type I to be returned when an input of type I is null. Used when revert(Object)
is invoked.public O execute(I input)
execute
in interface Conversion<I,O>
input
- the input value of type I to be converted to an object of type OvalueOnNullInput
if the input object is null.protected abstract O fromInput(I input)
input
- The object of type I to be converted to Opublic I revert(O input)
revert
in interface Conversion<I,O>
input
- the input of type O to be converted to an output IvalueOnNullOutput
if the input object is null.protected abstract I undo(O input)
input
- the input object to be converted to Ipublic O getValueOnNullInput()
execute(Object)
is invoked.public I getValueOnNullOutput()
revert(Object)
is invoked.public void setValueOnNullInput(O valueOnNullInput)
execute(Object)
is invoked with a null I..valueOnNullInput
- the default value of type T when converting from a null inputpublic void setValueOnNullOutput(I valueOnNullOutput)
revert(Object)
is invoked with a null O.valueOnNullOutput
- a default value of type I when converting from a null input