This class supports multiple representations of boolean values. For example, you can define conversions from different Strings such as "Yes, Y, 1" to true, and "No, N, 0" to false.
The reverse conversion from a Boolean to String (in BooleanConversion#revert(Boolean) will return the first String provided in this class constructor
Using the previous example, a call to revert(true) will produce "Yes" and a call revert(false) will produce "No".
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private String | |
| private final Set | |
| private final Set |
| Access | Constructor and Description |
|---|---|
| public | BooleanConversion(String[]
Strings that identify the boolean value true. The first element will be returned when executing valuesForTrue, String[] revert(true)Strings that identify the boolean value false. The first element will be returned when executing valuesForFalse)#revert(false)Creates conversions from String to Boolean. |
| public | BooleanConversion(Boolean
default Boolean value to be returned when the input String is null. Used when valueIfStringIsNull, String ObjectConversion#execute(String) is invoked.default String value to be returned when a Boolean input is null. Used when valueIfObjectIsNull, String[] BooleanConversion#revert(Boolean) is invoked.Strings that identify the boolean value true. The first element will be returned when executing valuesForTrue, String[] revert(true)Strings that identify the boolean value false. The first element will be returned when executing valuesForFalse)#revert(false)Creates a Conversion from String to Boolean with default values to return when the input is null. |
| Modifier and Type | Method and Description |
|---|---|
| protected Boolean | Returns: true if the input String is part ofBooleanConversion#trueValues, false if the input String is part of BooleanConversion#falseValues, or BooleanConversion#getValueIfStringIsNull() if the input String is null.a String to be converted into a Boolean value. input)Implements abstract com. |
| public static Boolean | Returns: the boolean value that the input string representsthe value that represents either booleanString, String[] true or falsea set of possible string values that represent trueValues, String[] true. If empty, then "true" will be assumed as the only acceptable representation.a set of possible string values that represent falseValues)false. If empty, then "false" will be assumed as the only acceptable representation.Returns the |
| private static Boolean | |
| private static String | |
| private static void | normalize(Collection<String>
a String collection with elements to be normalized. The original contents of the collection will be modified. strings)Normalizes the Strings in a given collection by trimming all elements and converting them to lower case. |
| public String | Returns: a String representation for this boolean value, or the value ofBooleanConversion#getValueIfObjectIsNull() if the Boolean input is null.the Boolean to be converted to a String input)Overrides com. Implements com. The return value depends on the list of values for true/false provided in the constructor of this class. |
| defaultForFalse | back to summary |
|---|---|
| private String defaultForFalse | |
| defaultForTrue | back to summary |
|---|---|
| private String defaultForTrue | |
| falseValues | back to summary |
|---|---|
| private final Set<String> falseValues | |
| trueValues | back to summary |
|---|---|
| private final Set<String> trueValues | |
| BooleanConversion | back to summary |
|---|---|
| public BooleanConversion(String[] valuesForTrue, String[] valuesForFalse) Creates conversions from String to Boolean. This default constructor assumes the output of a conversion should be null when input is null The list of Strings that identify "true" the list of Strings that identify "false" are mandatory. | |
| BooleanConversion | back to summary |
|---|---|
| public BooleanConversion(Boolean valueIfStringIsNull, String valueIfObjectIsNull, String[] valuesForTrue, String[] valuesForFalse) Creates a Conversion from String to Boolean with default values to return when the input is null. The list of Strings that identify "true" the list of Strings that identify "false" are mandatory.
| |
| fromString | back to summary |
|---|---|
| protected Boolean fromString(String input) Implements abstract com. Converts a String to a Boolean
| |
| getBoolean | back to summary |
|---|---|
| public static Boolean getBoolean(String booleanString, String[] trueValues, String[] falseValues) Returns the
| |
| getBoolean | back to summary |
|---|---|
| private static Boolean getBoolean(String defaultString, Set<String> trueValues, Set<String> falseValues) | |
| normalize | back to summary |
|---|---|
| private static String normalize(String string) Normalizes a given String by trimming whitespaces and converting it to lower case. | |
| normalize | back to summary |
|---|---|
| private static void normalize(Collection<String> strings) Normalizes the Strings in a given collection by trimming all elements and converting them to lower case.
| |
| revert | back to summary |
|---|---|
| public String revert(Boolean input) Overrides com. Implements com. Converts a Boolean back to a String The return value depends on the list of values for true/false provided in the constructor of this class.
| |