Here you can find the source of toBoolean(final Boolean bool)
Converts a Boolean to a boolean handling null by returning false .
Parameter | Description |
---|---|
bool | the boolean to convert |
public static boolean toBoolean(final Boolean bool)
//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(); } }