List of utility methods to do Boolean From
boolean | toBoolean(Object value) to Boolean if ((value == null || value instanceof Number && (((Number) value).longValue()) == 0L || value instanceof String && (value.equals("") || ((String) value).equalsIgnoreCase("false") || ((String) value).equalsIgnoreCase("no") || ((String) value).equalsIgnoreCase("0")) || value instanceof Boolean && value.equals(false))) { return false; return true; |
Boolean | toBoolean(Object value, Boolean defaultValue) to Boolean return toBoolean(value, null, null, defaultValue);
|
boolean | toBoolean(Object value, boolean defaultValue) to Boolean if (value == null) { return defaultValue; } else { return toBoolean(value); |
boolean | toBoolean(String baseString) to Boolean return toBoolean(baseString, true);
|
boolean | toBoolean(String content) to Boolean switch (content.toLowerCase().trim()) { case "on": case "true": case "yes": return true; case "off": case "false": case "no": ... |
Boolean | toBoolean(String flag) Converts a one-char Y/N String to Boolean. if ("Y".equals(flag)) { return true; if ("N".equals(flag)) { return false; throw new IllegalArgumentException("Flag should be Y/N"); |
boolean | toBoolean(String input, boolean defaultValue) to Boolean if (input == null) { return defaultValue; try { return Boolean.valueOf(input).booleanValue(); } catch (Exception e) { return defaultValue; |
boolean | toBoolean(String inString) to Boolean boolean retVal = false; if (inString.toUpperCase().equals("Y") || inString.toUpperCase().equals("TRUE") || inString.equalsIgnoreCase("Yes")) { retVal = true; } else if (inString.toUpperCase().equals("N") || inString.toUpperCase().equals("FALSE") || inString.equalsIgnoreCase("No")) { retVal = false; return retVal; |
boolean | toBoolean(String propertyValue) Converts the specified property value to a boolean. return (propertyValue == null) ? false : Boolean.valueOf(propertyValue).booleanValue();
|
boolean | toBoolean(String s) returns the boolean equivalent of a string, which is considered true if either "on", "true", or "yes" is found, ignoring case. return (s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("true") || s.equalsIgnoreCase("on") || s.equalsIgnoreCase("1")); |