Top Description Fields Constructors Methods
com.univocity.parsers.conversions

public abstract Class NullConversion<I, O>

extends Object
implements Conversion<I, O>
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.conversions.Conversion
Known Direct Subclasses
com.univocity.parsers.conversions.ObjectConversion, com.univocity.parsers.conversions.ToStringConversion
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.

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.

Author
Univocity Software Pty Ltd - [email protected]

Field Summary

Modifier and TypeField and Description
private O
private I

Constructor Summary

AccessConstructor and Description
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.

public
NullConversion(O
default value of type O to be returned when the input object I is null. Used when NullConversion#execute(Object) is invoked.
valueOnNullInput
,
I
default value of type I to be returned when an input of type I is null. Used when NullConversion#revert(Object) is invoked.
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 TypeMethod and Description
public O

Returns:

the conversion result, or the value of NullConversion#valueOnNullInput if the input object is null.
execute
(I
the input value of type I to be converted to an object of type O
input
)

Implements com.univocity.parsers.conversions.Conversion.execute.

Converts the given instance of type I to an instance of O
protected abstract O

Returns:

an instance of O, converted from the I input.
fromInput
(I
The object of type I to be converted to O
input
)

Creates an instance of O from a I object

public O

Returns:

the default value of type O used when converting from a null I
getValueOnNullInput
()

returns a default value of type O to be returned when the input of type I is null.

public I

Returns:

the default I instance used when converting from a null O
getValueOnNullOutput
()

returns default instance of I to be returned when an input of type O is null.

public I

Returns:

the conversion result, or the value of NullConversion#valueOnNullOutput if the input object is null.
revert
(O
the input of type O to be converted to an output I
input
)

Implements com.univocity.parsers.conversions.Conversion.revert.

Converts a value of type O back to a value of type I
public void
setValueOnNullInput(O
the default value of type T when converting from a null input
valueOnNullInput
)

defines the default value of type O which should be returned when NullConversion#execute(Object) is invoked with a null I..

public void
setValueOnNullOutput(I
a default value of type I when converting from a null input
valueOnNullOutput
)

defines the default value of type I which should be returned when NullConversion#revert(Object) is invoked with a null O.

protected abstract I

Returns:

the conversion result
undo
(O
the input object to be converted to I
input
)

Converts a value of type O back to I.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueOnNullInputback to summary
private O valueOnNullInput
valueOnNullOutputback to summary
private I valueOnNullOutput

Constructor Detail

NullConversionback to summary
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

NullConversionback to summary
public 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.

Parameters
valueOnNullInput:O

default value of type O to be returned when the input object I is null. Used when NullConversion#execute(Object) is invoked.

valueOnNullOutput:I

default value of type I to be returned when an input of type I is null. Used when NullConversion#revert(Object) is invoked.

Method Detail

executeback to summary
public O execute(I input)

Implements com.univocity.parsers.conversions.Conversion.execute.

Converts the given instance of type I to an instance of O

Parameters
input:I

the input value of type I to be converted to an object of type O

Returns:O

the conversion result, or the value of NullConversion#valueOnNullInput if the input object is null.

Annotations
@Override
fromInputback to summary
protected abstract O fromInput(I input)

Creates an instance of O from a I object

Parameters
input:I

The object of type I to be converted to O

Returns:O

an instance of O, converted from the I input.

getValueOnNullInputback to summary
public O getValueOnNullInput()

returns a default value of type O to be returned when the input of type I is null. Used when NullConversion#execute(Object) is invoked.

Returns:O

the default value of type O used when converting from a null I

getValueOnNullOutputback to summary
public I getValueOnNullOutput()

returns default instance of I to be returned when an input of type O is null. Used when NullConversion#revert(Object) is invoked.

Returns:I

the default I instance used when converting from a null O

revertback to summary
public I revert(O input)

Implements com.univocity.parsers.conversions.Conversion.revert.

Converts a value of type O back to a value of type I

Parameters
input:O

the input of type O to be converted to an output I

Returns:I

the conversion result, or the value of NullConversion#valueOnNullOutput if the input object is null.

Annotations
@Override
setValueOnNullInputback to summary
public void setValueOnNullInput(O valueOnNullInput)

defines the default value of type O which should be returned when NullConversion#execute(Object) is invoked with a null I..

Parameters
valueOnNullInput:O

the default value of type T when converting from a null input

setValueOnNullOutputback to summary
public void setValueOnNullOutput(I valueOnNullOutput)

defines the default value of type I which should be returned when NullConversion#revert(Object) is invoked with a null O.

Parameters
valueOnNullOutput:I

a default value of type I when converting from a null input

undoback to summary
protected abstract I undo(O input)

Converts a value of type O back to I.

Parameters
input:O

the input object to be converted to I

Returns:I

the conversion result