Java Number Negate negate(Boolean bool)

Here you can find the source of negate(Boolean bool)

Description

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; 

License

Apache License

Parameter

Parameter Description
bool the Boolean to negate, may be null

Return

the negated Boolean, or null if null input

Declaration

public static Boolean negate(Boolean bool) 

Method Source Code

//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);
    }
}

Related

  1. negate(Boolean _value)
  2. negate(Boolean bool)
  3. negate(boolean[] posit)
  4. negate(Comparable v)
  5. negate(double[] a)
  6. negate(double[] output, double[] a)