Java BigDecimal Equal equals(final BigDecimal pValue1, final BigDecimal pValue2)

Here you can find the source of equals(final BigDecimal pValue1, final BigDecimal pValue2)

Description

Check to see if the big decimals are equal (null safe).

License

Open Source License

Parameter

Parameter Description
pValue1 The first value.
pValue2 The second value.

Declaration

public static final boolean equals(final BigDecimal pValue1, final BigDecimal pValue2) 

Method Source Code

//package com.java2s;
/**/*  w w w .ja v a  2  s.co m*/
 * (C) Copyright 2007, Deft Labs.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.math.BigInteger;
import java.math.BigDecimal;

public class Main {
    /**
     * Check to see if doubles are equal (null safe).
     * @param pValue1 The first value.
     * @param pValue2 The second value.
     */
    public static final boolean equals(final Double pValue1, final Double pValue2) {
        if (pValue1 != null)
            return pValue1.equals(pValue2);
        if (pValue2 != null)
            return pValue1.equals(pValue2);
        return false;
    }

    /**
     * Check to see if longs are equal (null safe).
     * @param pValue1 The first value.
     * @param pValue2 The second value.
     */
    public static final boolean equals(final Long pValue1, final Long pValue2) {
        if (pValue1 != null)
            return pValue1.equals(pValue2);
        if (pValue2 != null)
            return pValue1.equals(pValue2);
        return false;
    }

    /**
     * Check to see if ints are equal (null safe).
     * @param pValue1 The first value.
     * @param pValue2 The second value.
     */
    public static final boolean equals(final Integer pValue1, final Integer pValue2) {
        if (pValue1 != null)
            return pValue1.equals(pValue2);
        if (pValue2 != null)
            return pValue1.equals(pValue2);
        return false;
    }

    /**
     * Check to see if the shorts are equal (null safe).
     * @param pValue1 The first value.
     * @param pValue2 The second value.
     */
    public static final boolean equals(final Short pValue1, final Short pValue2) {
        if (pValue1 != null)
            return pValue1.equals(pValue2);
        if (pValue2 != null)
            return pValue1.equals(pValue2);
        return false;
    }

    /**
     * Check to see if the big ints are equal (null safe).
     * @param pValue1 The first value.
     * @param pValue2 The second value.
     */
    public static final boolean equals(final BigInteger pValue1, final BigInteger pValue2) {
        if (pValue1 == null || pValue2 == null)
            return false;
        return pValue1.equals(pValue2);
    }

    /**
     * Check to see if the big decimals are equal (null safe).
     * @param pValue1 The first value.
     * @param pValue2 The second value.
     */
    public static final boolean equals(final BigDecimal pValue1, final BigDecimal pValue2) {
        if (pValue1 == null || pValue2 == null)
            return false;
        return pValue1.equals(pValue2);
    }
}

Related

  1. equals(BigDecimal bd1, BigDecimal bd2)
  2. equals(BigDecimal decimal, double number)
  3. equals(BigDecimal left, BigDecimal right, int scale)
  4. Equals(BigDecimal one, BigDecimal two)
  5. equals(final BigDecimal b0, final BigDecimal b1, final double delta)
  6. equalsBigDecimal(BigDecimal bd1, BigDecimal bd2)
  7. isEqual(BigDecimal aLhs, BigDecimal aRhs)
  8. isEqual(BigDecimal n1, BigDecimal n2, int precision)
  9. isEqual(BigDecimal value1, BigDecimal value2)