Java Code Examples for org.apache.commons.lang3.math.NumberUtils#INTEGER_ZERO

The following examples show how to use org.apache.commons.lang3.math.NumberUtils#INTEGER_ZERO . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * <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>
 *   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() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 2
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Converts a Boolean to a Integer using the convention that
 * {@code zero} is {@code false}.</p>
 *
 * <p>{@code null} will be converted to {@code null}.</p>
 *
 * <pre>
 *   BooleanUtils.toIntegerObject(Boolean.TRUE)  = Integer.valueOf(1)
 *   BooleanUtils.toIntegerObject(Boolean.FALSE) = Integer.valueOf(0)
 * </pre>
 *
 * @param bool  the Boolean to convert
 * @return one if Boolean.TRUE, zero if Boolean.FALSE, {@code null} if {@code null}
 */
public static Integer toIntegerObject(Boolean bool) {
    if (bool == null) {
        return null;
    }
    return bool.booleanValue() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 3
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * <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>
 *   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() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 4
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Converts a Boolean to a Integer using the convention that
 * {@code zero} is {@code false}.</p>
 *
 * <p>{@code null} will be converted to {@code null}.</p>
 *
 * <pre>
 *   BooleanUtils.toIntegerObject(Boolean.TRUE)  = Integer.valueOf(1)
 *   BooleanUtils.toIntegerObject(Boolean.FALSE) = Integer.valueOf(0)
 * </pre>
 *
 * @param bool  the Boolean to convert
 * @return one if Boolean.TRUE, zero if Boolean.FALSE, {@code null} if {@code null}
 */
public static Integer toIntegerObject(final Boolean bool) {
    if (bool == null) {
        return null;
    }
    return bool.booleanValue() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 5
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Converts a Boolean to a Integer using the convention that
 * {@code zero} is {@code false}.</p>
 *
 * <p>{@code null} will be converted to {@code null}.</p>
 *
 * <pre>
 *   BooleanUtils.toIntegerObject(Boolean.TRUE)  = Integer.valueOf(1)
 *   BooleanUtils.toIntegerObject(Boolean.FALSE) = Integer.valueOf(0)
 * </pre>
 *
 * @param bool  the Boolean to convert
 * @return one if Boolean.TRUE, zero if Boolean.FALSE, {@code null} if {@code null}
 */
public static Integer toIntegerObject(Boolean bool) {
    if (bool == null) {
        return null;
    }
    return bool.booleanValue() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 6
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Converts a boolean to an Integer using the convention that
 * <code>zero</code> is <code>false</code>.</p>
 * 
 * <pre>
 *   BooleanUtils.toIntegerObject(true)  = new Integer(1)
 *   BooleanUtils.toIntegerObject(false) = new Integer(0)
 * </pre>
 *
 * @param bool  the boolean to convert
 * @return one if <code>true</code>, zero if <code>false</code>
 */
public static Integer toIntegerObject(boolean bool) {
    return bool ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 7
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Converts a boolean to an Integer using the convention that
 * {@code zero} is {@code false}.</p>
 *
 * <pre>
 *   BooleanUtils.toIntegerObject(true)  = Integer.valueOf(1)
 *   BooleanUtils.toIntegerObject(false) = Integer.valueOf(0)
 * </pre>
 *
 * @param bool  the boolean to convert
 * @return one if {@code true}, zero if {@code false}
 */
public static Integer toIntegerObject(boolean bool) {
    return bool ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 8
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Converts a boolean to an Integer using the convention that
 * <code>zero</code> is <code>false</code>.</p>
 * 
 * <pre>
 *   BooleanUtils.toIntegerObject(true)  = new Integer(1)
 *   BooleanUtils.toIntegerObject(false) = new Integer(0)
 * </pre>
 *
 * @param bool  the boolean to convert
 * @return one if <code>true</code>, zero if <code>false</code>
 */
public static Integer toIntegerObject(boolean bool) {
    return bool ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 9
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Converts a boolean to an Integer using the convention that
 * {@code zero} is {@code false}.</p>
 *
 * <pre>
 *   BooleanUtils.toIntegerObject(true)  = Integer.valueOf(1)
 *   BooleanUtils.toIntegerObject(false) = Integer.valueOf(0)
 * </pre>
 *
 * @param bool  the boolean to convert
 * @return one if {@code true}, zero if {@code false}
 */
public static Integer toIntegerObject(final boolean bool) {
    return bool ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}
 
Example 10
Source Project: astor   File: BooleanUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * <p>Converts a boolean to an Integer using the convention that
 * {@code zero} is {@code false}.</p>
 *
 * <pre>
 *   BooleanUtils.toIntegerObject(true)  = Integer.valueOf(1)
 *   BooleanUtils.toIntegerObject(false) = Integer.valueOf(0)
 * </pre>
 *
 * @param bool  the boolean to convert
 * @return one if {@code true}, zero if {@code false}
 */
public static Integer toIntegerObject(boolean bool) {
    return bool ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
}