List of utility methods to do Boolean From
boolean | toBoolean(final Object value, final boolean defaultValue) to Boolean final Boolean v = toBoolean(value); return v == null ? defaultValue : v.booleanValue(); |
Boolean | toBoolean(final Object valueRep) to Boolean return Boolean.parseBoolean(String.valueOf(valueRep));
|
boolean | toBoolean(final String booleanString, final boolean defaultValue) Retrieves whether the given value is true return toBoolean(booleanString, TRUE, FALSE, defaultValue);
|
boolean | toBoolean(final String s) Convert a string into a boolean primitive (i.e. String temp = s.toUpperCase(); return "TRUE".equals(temp) || "YES".equals(temp) || "ON".equals(temp); |
boolean | toBoolean(final String s) to Boolean return "true".equalsIgnoreCase(s) || "1".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s) || "enable".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s); |
boolean | toBoolean(final String source) Returns true if the source string evaulates (case insensative and trimmed) to true , yes , or on .
return toBoolean(source, false);
|
String | toBoolean(final String string) to Boolean return Boolean.valueOf(string).toString();
|
boolean | toBoolean(final String strTransparent) Parse a boolean from a string value. if (strTransparent == null) { return false; return Boolean.parseBoolean(strTransparent.trim()); |
Object | toBoolean(final String val) to Boolean if (val.equalsIgnoreCase("on")) { return Boolean.TRUE; } else if (val.equalsIgnoreCase("off")) { return Boolean.FALSE; return Boolean.parseBoolean(val); |
Boolean | toBoolean(final String value) Convert a String to a boolean using the smart way
if (value == null) { return null; if ("true".equals(value) || "yes".equals(value) || "ok".equals(value)) { return true; } else if ("false".equals(value) || "no".equals(value) || "ko".equals(value)) { return false; try { return Integer.valueOf(value) > 0; } catch (final NumberFormatException e) { throw new IllegalArgumentException(value + " is not a valid boolean value"); |