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

The following examples show how to use org.apache.commons.lang3.math.NumberUtils#INTEGER_ONE . 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 check out the related API usage on the sidebar.
Example 1
Source File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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 File: BooleanUtils.java    From astor with 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;
}