public class NullStringConversion extends java.lang.Object implements Conversion<java.lang.Object,java.lang.Object>
This class supports multiple representations of null values. For example, you can define conversions from different Strings such as "N/A, ?, -" to null.
The reverse conversion from a null to String (in revert(Object)
will return the first String provided in this class constructor if the object is null.
Using the previous example, a call to revert(Object)
will produce "N/A".
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
defaultNullString |
private java.util.Set<java.lang.String> |
nullStrings |
Constructor and Description |
---|
NullStringConversion(java.lang.String... nullRepresentations)
Creates conversions from Strings to null.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
execute(java.lang.Object input)
Converts an Object to null.
|
java.lang.Object |
revert(java.lang.Object input)
Converts a null input to a String representation.
|
private final java.util.Set<java.lang.String> nullStrings
private final java.lang.String defaultNullString
public NullStringConversion(java.lang.String... nullRepresentations)
The list of Strings that identify nulls are mandatory.
nullRepresentations
- Strings that identify a true value. The first element will be returned when executing revert(Object)
public java.lang.Object execute(java.lang.Object input)
execute
in interface Conversion<java.lang.Object,java.lang.Object>
input
- an Object to be converted to null.public java.lang.Object revert(java.lang.Object input)
revert
in interface Conversion<java.lang.Object,java.lang.Object>
input
- an Object that, if null, will be transformed to a String.