Here you can find the source of negate(Boolean bool)
Negates the specified boolean.
If null
is passed in, null
will be returned.
BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE; BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE; BooleanUtils.negate(null) = null;
Parameter | Description |
---|---|
bool | the Boolean to negate, may be null |
null
if null
input
public static Boolean negate(Boolean bool)
//package com.java2s; /*//from w w w. ja v a 2 s. co m * Copyright 2002-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * <p>Negates the specified boolean.</p> * * <p>If <code>null</code> is passed in, <code>null</code> will be returned.</p> * * <pre> * BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE; * BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE; * BooleanUtils.negate(null) = null; * </pre> * * @param bool the Boolean to negate, may be null * @return the negated Boolean, or <code>null</code> if <code>null</code> input */ public static Boolean negate(Boolean bool) { if (bool == null) { return null; } return (bool.booleanValue() ? Boolean.FALSE : Boolean.TRUE); } }