List of usage examples for java.lang Boolean booleanValue
@HotSpotIntrinsicCandidate public boolean booleanValue()
From source file:org.syphr.mythtv.ws.impl.ServiceUtils.java
public static boolean toPrimitive(Boolean b) { if (b == null) { return false; }/*from www .j av a 2 s . c o m*/ return b.booleanValue(); }
From source file:Main.java
public static boolean[] toBooleanArray(List<Boolean> list, boolean defaultValue) { if (isEmpty(list)) { return new boolean[0]; }//from w w w. j av a 2 s . com boolean[] array = new boolean[list.size()]; for (int I = 0; I < list.size(); I++) { Boolean v = list.get(I); if (v == null) { array[I] = defaultValue; } else { array[I] = v.booleanValue(); } } return array; }
From source file:Main.java
/** * Converts to primitive array./*from www. j a v a 2 s . c om*/ */ public static boolean[] values(Boolean[] array) { boolean[] dest = new boolean[array.length]; for (int i = 0; i < array.length; i++) { Boolean v = array[i]; if (v != null) { dest[i] = v.booleanValue(); } } return dest; }
From source file:Main.java
/** * Sets or removes the given key from the specified style and returns the * new style. If value is null then the flag is toggled. * /*from ww w . j a v a 2s. c om*/ * @param style * String of the form stylename[;key=value]. * @param key * Key of the style to be changed. * @param flag * Integer for the bit to be changed. * @param value * Optional boolean value for the given flag. */ public static String setStyleFlag(String style, String key, int flag, Boolean value) { if (style == null || style.length() == 0) { if (value == null || value.booleanValue()) { style = key + "=" + flag; } else { style = key + "=0"; } } else { int index = style.indexOf(key + "="); if (index < 0) { String sep = (style.endsWith(";")) ? "" : ";"; if (value == null || value.booleanValue()) { style = style + sep + key + "=" + flag; } else { style = style + sep + key + "=0"; } } else { int cont = style.indexOf(";", index); String tmp = ""; int result = 0; if (cont < 0) { tmp = style.substring(index + key.length() + 1); } else { tmp = style.substring(index + key.length() + 1, cont); } if (value == null) { result = Integer.parseInt(tmp) ^ flag; } else if (value.booleanValue()) { result = Integer.parseInt(tmp) | flag; } else { result = Integer.parseInt(tmp) & ~flag; } style = style.substring(0, index) + key + "=" + result + ((cont >= 0) ? style.substring(cont) : ""); } } return style; }
From source file:Main.java
/** * <p>Converts a Boolean to an int specifying the conversion values.</p> * //www . j a v a 2 s . c om * <pre> * BooleanUtils.toInteger(Boolean.TRUE, 1, 0, 2) = 1 * BooleanUtils.toInteger(Boolean.FALSE, 1, 0, 2) = 0 * BooleanUtils.toInteger(null, 1, 0, 2) = 2 * </pre> * * @param bool the Boolean to convert * @param trueValue the value to return if <code>true</code> * @param falseValue the value to return if <code>false</code> * @param nullValue the value to return if <code>null</code> * @return the appropriate value */ public static int toInteger(Boolean bool, int trueValue, int falseValue, int nullValue) { if (bool == null) { return nullValue; } return bool.booleanValue() ? trueValue : falseValue; }
From source file:Main.java
public static boolean[] toPrimitive(final Boolean[] array, final boolean valueForNull) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_BOOLEAN_ARRAY; }/*from w w w.jav a 2s.c o m*/ final boolean[] result = new boolean[array.length]; for (int i = 0; i < array.length; i++) { final Boolean b = array[i]; result[i] = (b == null ? valueForNull : b.booleanValue()); } return result; }
From source file:com.knowbout.hibernate.TransactionManager.java
public static boolean isRollbackOnly() { Boolean isRollback = rollbackOnly.get(); if (isRollback != null) { return isRollback.booleanValue(); } else {// w w w. j a v a 2s. c o m return false; } }
From source file:org.apache.solr.client.solrj.impl.HttpClientConfigurer.java
public static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) { if (bool == null) { return valueIfNull; }//from w w w . j a va2 s. c o m return bool.booleanValue() ? true : false; }
From source file:Main.java
/** * <p>Converts a Boolean to an Integer specifying the conversion values.</p> * /*from www.j ava 2s.c o m*/ * <pre> * BooleanUtils.toIntegerObject(Boolean.TRUE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(1) * BooleanUtils.toIntegerObject(Boolean.FALSE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(0) * BooleanUtils.toIntegerObject(null, new Integer(1), new Integer(0), new Integer(2)) = new Integer(2) * </pre> * * @param bool the Boolean to convert * @param trueValue the value to return if <code>true</code>, * may be <code>null</code> * @param falseValue the value to return if <code>false</code>, * may be <code>null</code> * @param nullValue the value to return if <code>null</code>, * may be <code>null</code> * @return the appropriate value */ public static Integer toIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue) { if (bool == null) { return nullValue; } return bool.booleanValue() ? trueValue : falseValue; }
From source file:Main.java
/** * <p>Converts a Boolean to a String returning one of the input Strings.</p> * // ww w.j a v a 2s . c o m * <pre> * BooleanUtils.toString(Boolean.TRUE, "true", "false", null) = "true" * BooleanUtils.toString(Boolean.FALSE, "true", "false", null) = "false" * BooleanUtils.toString(null, "true", "false", null) = null; * </pre> * * @param bool the Boolean to check * @param trueString the String to return if <code>true</code>, * may be <code>null</code> * @param falseString the String to return if <code>false</code>, * may be <code>null</code> * @param nullString the String to return if <code>null</code>, * may be <code>null</code> * @return one of the three input Strings */ public static String toString(Boolean bool, String trueString, String falseString, String nullString) { if (bool == null) { return nullString; } return bool.booleanValue() ? trueString : falseString; }