Java Boolean From toBoolean(final Boolean bool)

Here you can find the source of toBoolean(final Boolean bool)

Description

Converts a Boolean to a boolean handling null by returning false .

License

Open Source License

Parameter

Parameter Description
bool the boolean to convert

Return

true or false , null returns false

Declaration

public static boolean toBoolean(final Boolean bool) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w w  w . ja  va 2s.c  o  m
     * <p>
     * Converts a Boolean to a boolean handling {@code null} by returning
     * {@code false}.
     * </p>
     *
     * <pre>
     *   BooleanUtils.toBoolean(Boolean.TRUE)  = true
     *   BooleanUtils.toBoolean(Boolean.FALSE) = false
     *   BooleanUtils.toBoolean(null)          = false
     * </pre>
     *
     * @param bool
     *            the boolean to convert
     * @return {@code true} or {@code false}, {@code null} returns {@code false}
     */
    public static boolean toBoolean(final Boolean bool) {
        return bool != null && bool.booleanValue();
    }
}

Related

  1. toBoolean(byte[] data, int offset)
  2. toBoolean(byte[] value)
  3. toBoolean(char c)
  4. toBoolean(double value)
  5. toBoolean(final Boolean bool)
  6. toBoolean(final byte[] b)
  7. toBoolean(final Object obj, final boolean defaultValue)
  8. toBoolean(final Object value)
  9. toBoolean(final Object value, final boolean defaultValue)