List of utility methods to do Boolean From
boolean[] | toBooleanArray(final Object[] array) to Boolean Array if (array == null) { return new boolean[0]; final boolean[] retVal = new boolean[array.length]; try { for (int i = 0; i < array.length; i++) { retVal[i] = Boolean.parseBoolean(String.valueOf(array[i])); return retVal; } catch (Exception e) { return new boolean[0]; |
boolean[] | toBooleanArray(int[] intArray, int n) to Boolean Array boolean[] array = new boolean[n]; for (int element : intArray) { array[element] = true; return array; |
boolean[] | toBooleanArray(Object[] vs) to Boolean Array boolean[] nvs = new boolean[vs.length]; for (int i = 0; i < vs.length; i++) { nvs[i] = (boolean) vs[i]; return nvs; |
boolean | toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) to Boolean Default If Null if (bool == null) { return valueIfNull; return bool; |
boolean | toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) Converts a Boolean to a boolean handling BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false BooleanUtils.toBooleanDefaultIfNull(null, true) = true if (bool == null) { return valueIfNull; return bool.booleanValue() ? true : false; |
Boolean | toBooleanObject(final int val) Method to convert int to Boolean object return val != 0 ? Boolean.TRUE : Boolean.FALSE; |
Boolean | toBooleanObject(final String str) to Boolean Object if (str == "true") { return Boolean.TRUE; if (str == null) { return null; switch (str.length()) { case 1: { ... |
Boolean | toBooleanObject(int value, int trueValue, int falseValue, int nullValue) Converts an int to a Boolean specifying the conversion values. NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. if (value == trueValue) { return Boolean.TRUE; if (value == falseValue) { return Boolean.FALSE; if (value == nullValue) { return null; ... |
Boolean | toBooleanObject(int value, int trueValue, int falseValue, int nullValue) to Boolean Object if (value == trueValue) { return Boolean.TRUE; } else if (value == falseValue) { return Boolean.FALSE; } else if (value == nullValue) { return null; throw new IllegalArgumentException("The Integer did not match any specified value"); ... |
Boolean | toBooleanObject(String str) to Boolean Object return str != null ? Boolean.valueOf(str) : null;
|