Java BigDecimal Equal isEqual(BigDecimal aLhs, BigDecimal aRhs)

Here you can find the source of isEqual(BigDecimal aLhs, BigDecimal aRhs)

Description

FILLIN

License

Apache License

Parameter

Parameter Description
aLhs a parameter
aRhs a parameter

Declaration

public static boolean isEqual(BigDecimal aLhs, BigDecimal aRhs) 

Method Source Code


//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License");

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;

public class Main {
    /**/*from  w w w .  j  a v  a  2 s.  c om*/
     * FILLIN
     * 
     * @param       aLhs
     * @param       aRhs
     * 
     * @return
     */
    public static boolean isEqual(boolean aLhs, boolean aRhs) {
        return (aLhs == aRhs);
    }

    /**
     * FILLIN
     * 
     * @param       aLhs
     * @param       aRhs
     * 
     * @return
     */
    public static boolean isEqual(int aLhs, int aRhs) {
        return (aLhs == aRhs);
    }

    /**
     * FILLIN
     * 
     * @param       aLhs
     * @param       aRhs
     * 
     * @return
     */
    public static <T> boolean isEqual(T aLhs, T aRhs) {
        return ((aLhs == null && aRhs == null) || (aLhs != null && aRhs != null && aLhs.equals(aRhs)));
    }

    /**
     * FILLIN
     * 
     * @param       aLhs
     * @param       aRhs
     * 
     * @return
     */
    public static boolean isEqual(BigDecimal aLhs, BigDecimal aRhs) {
        return ((aLhs == null && aRhs == null) || (aLhs != null && aRhs != null && aLhs.compareTo(aRhs) == 0));
    }

    /**
     * FILLIN
     * 
     * @param       aLhs
     * @param       aRhs
     * 
     * @return
     */
    public static boolean isEqual(Date aLhs, Date aRhs) {
        return ((aLhs == null && aRhs == null)
                || (aLhs != null && aRhs != null && (aLhs.getTime() / 1000) == (aRhs.getTime() / 1000)));
    }

    /**
     * FILLIN
     * 
     * @param       aLhsSet
     * @param       aRhsSet
     * 
     * @return
     */
    public static <T> boolean isEqual(Collection<T> aLhsSet, Collection<T> aRhsSet) {
        boolean myIsEqual = false;

        if (aLhsSet != null && aRhsSet != null) {
            if (aLhsSet.size() == aRhsSet.size()) {
                myIsEqual = true;

                Iterator<T> myLhsIterator = aLhsSet.iterator();
                Iterator<T> myRhsIterator = aRhsSet.iterator();

                while (myLhsIterator.hasNext()) {
                    Object myLhs = myLhsIterator.next();
                    Object myRhs = myRhsIterator.next();

                    myIsEqual = myLhs.equals(myRhs);
                }
            }
        } else if (aLhsSet == null && aRhsSet == null) {
            myIsEqual = true;
        }

        return myIsEqual;
    }
}

Related

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