Class NullConversion<I,O>
java.lang.Object
com.univocity.parsers.conversions.NullConversion<I,O>
- Type Parameters:
I
- The object type resulting from conversions of values of type O.O
- The object type resulting from conversions of values of type I.
- All Implemented Interfaces:
Conversion<I,
O>
- Direct Known Subclasses:
ObjectConversion
,ToStringConversion
Default implementation for conversions from input Objects of type I to output Objects of type 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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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. -
Method Summary
Modifier and TypeMethodDescriptionConverts the given instance of type I to an instance of Oprotected abstract O
Creates an instance of O from a I objectreturns a default value of type O to be returned when the input of type I is null.returns default instance of I to be returned when an input of type O is null.Converts a value of type O back to a value of type Ivoid
setValueOnNullInput
(O valueOnNullInput) defines the default value of type O which should be returned whenexecute(Object)
is invoked with a null I..void
setValueOnNullOutput
(I valueOnNullOutput) defines the default value of type I which should be returned whenrevert(Object)
is invoked with a null O.protected abstract I
Converts a value of type O back to I.
-
Field Details
-
valueOnNullInput
-
valueOnNullOutput
-
-
Constructor Details
-
NullConversion
public NullConversion()Creates a Conversion from an object to another object of a different type, with default values to return when the input is null. The default constructor assumes the output of a conversion should be null when input is null -
NullConversion
Creates a Conversion from an object to another object of a different type, with default values to return when the input is null.- Parameters:
valueOnNullInput
- default value of type O to be returned when the input object I is null. Used whenexecute(Object)
is invoked.valueOnNullOutput
- default value of type I to be returned when an input of type I is null. Used whenrevert(Object)
is invoked.
-
-
Method Details
-
execute
Converts the given instance of type I to an instance of O- Specified by:
execute
in interfaceConversion<I,
O> - Parameters:
input
- the input value of type I to be converted to an object of type O- Returns:
- the conversion result, or the value of
valueOnNullInput
if the input object is null.
-
fromInput
Creates an instance of O from a I object- Parameters:
input
- The object of type I to be converted to O- Returns:
- an instance of O, converted from the I input.
-
revert
Converts a value of type O back to a value of type I- Specified by:
revert
in interfaceConversion<I,
O> - Parameters:
input
- the input of type O to be converted to an output I- Returns:
- the conversion result, or the value of
valueOnNullOutput
if the input object is null.
-
undo
Converts a value of type O back to I.- Parameters:
input
- the input object to be converted to I- Returns:
- the conversion result
-
getValueOnNullInput
returns a default value of type O to be returned when the input of type I is null. Used whenexecute(Object)
is invoked.- Returns:
- the default value of type O used when converting from a null I
-
getValueOnNullOutput
returns default instance of I to be returned when an input of type O is null. Used whenrevert(Object)
is invoked.- Returns:
- the default I instance used when converting from a null O
-
setValueOnNullInput
defines the default value of type O which should be returned whenexecute(Object)
is invoked with a null I..- Parameters:
valueOnNullInput
- the default value of type T when converting from a null input
-
setValueOnNullOutput
defines the default value of type I which should be returned whenrevert(Object)
is invoked with a null O.- Parameters:
valueOnNullOutput
- a default value of type I when converting from a null input
-