List of usage examples for java.lang Boolean booleanValue
@HotSpotIntrinsicCandidate public boolean booleanValue()
From source file:Main.java
/** * <p>Negates the specified boolean.</p> * * <p>If {@code null} is passed in, {@code null} will be returned.</p> * * <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p> * * <pre>//from w w w. j av a 2s. c o m * BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE; * BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE; * BooleanUtils.negate(null) = null; * </pre> * * @param bool the Boolean to negate, may be null * @return the negated Boolean, or {@code null} if {@code null} input */ public static Boolean negate(final Boolean bool) { if (bool == null) { return null; } return bool.booleanValue() ? Boolean.FALSE : Boolean.TRUE; }
From source file:info.magnolia.cms.util.BooleanUtil.java
/** * Behaves much like org.apache.commons.lang.BooleanUtils but returns the defaultValue if * the input string is null, empty, or unrecognized. *///from ww w.j a v a2s . c o m public static boolean toBoolean(String s, boolean defaultValue) { final Boolean b = BooleanUtils.toBooleanObject(s); return b == null ? defaultValue : b.booleanValue(); }
From source file:Main.java
/** * <p>Converts a Boolean to a Integer using the convention that * <code>zero</code> is <code>false</code>.</p> * * <p><code>null</code> will be converted to <code>null</code>.</p> * * <pre>/*from www.ja v a 2s .com*/ * BooleanUtils.toIntegerObject(Boolean.TRUE) = new Integer(1) * BooleanUtils.toIntegerObject(Boolean.FALSE) = new Integer(0) * </pre> * * @param bool the Boolean to convert * @return one if Boolean.TRUE, zero if Boolean.FALSE, <code>null</code> if <code>null</code> */ public static Integer toIntegerObject(Boolean bool) { if (bool == null) { return null; } return bool.booleanValue() ? 1 : 0; }
From source file:Main.java
/** * <p>Converts a Boolean to a boolean handling <code>null</code> * by returning <code>false</code>.</p> * * <pre>/*from w w w. j ava2s . c o m*/ * BooleanUtils.toBoolean(Boolean.TRUE) = true * BooleanUtils.toBoolean(Boolean.FALSE) = false * BooleanUtils.toBoolean(null) = false * </pre> * * @param bool the boolean to convert * @return <code>true</code> or <code>false</code>, * <code>null</code> returns <code>false</code> */ public static boolean toBoolean(Boolean bool) { if (bool == null) { return false; } return bool.booleanValue() ? true : false; }
From source file:Main.java
public static boolean evaluateXPathBool(final Node inNode, final String xpath) throws Exception { Boolean xPathBool = (Boolean) getNodesListXpath(xpath, inNode, "", "", XPathConstants.BOOLEAN); return xPathBool.booleanValue(); }
From source file:Main.java
public static boolean isWindowActive(Window window) { if (getJavaVersion() >= 1.4) { try {/*from www . j a v a 2 s. c o m*/ Class paramTypes[] = null; Object args[] = null; Method m = window.getClass().getMethod("isActive", paramTypes); Boolean b = (Boolean) m.invoke(window, args); return b.booleanValue(); } catch (Exception ex) { } } return true; }
From source file:Main.java
/** * <p>Converts a Boolean to a boolean handling {@code null}.</p> * * <pre>/*from w ww .j a v a2 s . com*/ * BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true * BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false * BooleanUtils.toBooleanDefaultIfNull(null, true) = true * </pre> * * @param bool the boolean to convert * @param valueIfNull the boolean value to return if {@code null} * @return {@code true} or {@code false} */ public static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) { if (bool == null) { return valueIfNull; } return bool.booleanValue(); }
From source file:Main.java
/** * <p>Checks if a <code>Boolean</code> value is <code>false</code>, * handling <code>null</code> by returning <code>false</code>.</p> * * <pre>/*from w w w.java2s. com*/ * BooleanUtils.isFalse(Boolean.TRUE) = false * BooleanUtils.isFalse(Boolean.FALSE) = true * BooleanUtils.isFalse(null) = false * </pre> * * @param bool the boolean to check, null returns <code>false</code> * @return <code>true</code> only if the input is non-null and false * @since 2.1 */ public static boolean isFalse(Boolean bool) { if (bool == null) { return false; } return bool.booleanValue() ? false : true; }
From source file:Main.java
/** * <p>Converts a Boolean to a boolean handling {@code null}.</p> * * <pre>//from w w w.ja v a 2 s. c o m * BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true * BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false * BooleanUtils.toBooleanDefaultIfNull(null, true) = true * </pre> * * @param bool the boolean to convert * @param valueIfNull the boolean value to return if {@code null} * @return {@code true} or {@code false} */ public static boolean toBooleanDefaultIfNull(final Boolean bool, final boolean valueIfNull) { if (bool == null) { return valueIfNull; } return bool.booleanValue(); }
From source file:Main.java
/** * <p>Converts a Boolean to a boolean handling <code>null</code>.</p> * //from w ww . j a va2s . c om * <pre> * BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true * BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false * BooleanUtils.toBooleanDefaultIfNull(null, true) = true * </pre> * * @param bool the boolean to convert * @param valueIfNull the boolean value to return if <code>null</code> * @return <code>true</code> or <code>false</code> */ public static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) { if (bool == null) { return valueIfNull; } return bool.booleanValue() ? true : false; }