Java Number Equal areEqual(boolean aThis, boolean aThat)

Here you can find the source of areEqual(boolean aThis, boolean aThat)

Description

Equals for boolean fields.

License

Apache License

Declaration

static boolean areEqual(boolean aThis, boolean aThat) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /** Equals for <tt>boolean</tt> fields. */
    static boolean areEqual(boolean aThis, boolean aThat) {
        return aThis == aThat;
    }//from  w w  w . j  a  v  a  2  s .  com

    /** Equals for <tt>char</tt> fields. */
    static boolean areEqual(char aThis, char aThat) {
        return aThis == aThat;
    }

    /**
     Equals for <tt>long</tt> fields.
          
     <P>Note that <tt>byte</tt>, <tt>short</tt>, and <tt>int</tt> are handled by this method, through
     implicit conversion.
    */
    static boolean areEqual(long aThis, long aThat) {
        return aThis == aThat;
    }

    /** Equals for <tt>float</tt> fields. */
    static boolean areEqual(float aThis, float aThat) {
        return Float.floatToIntBits(aThis) == Float.floatToIntBits(aThat);
    }

    /** Equals for <tt>double</tt> fields. */
    static boolean areEqual(double aThis, double aThat) {
        return Double.doubleToLongBits(aThis) == Double.doubleToLongBits(aThat);
    }

    /**
     Equals for possibly-<tt>null</tt> object field.
         
     <P><em>Does not include arrays</em>. (This restriction will likely be removed in a future version.)
    */
    static boolean areEqual(Object aThis, Object aThat) {
        if (isArray(aThis) || isArray(aThat)) {
            throw new IllegalArgumentException("This method does not currently support arrays.");
        }
        return aThis == null ? aThat == null : aThis.equals(aThat);
    }

    private static boolean isArray(Object aObject) {
        return aObject != null && aObject.getClass().isArray();
    }
}

Related

  1. areEqual(boolean aThis, boolean aThat)
  2. areEqual(boolean aThis, boolean aThat)
  3. areEqual(boolean c1, boolean c2)
  4. areEqual(double d1, double d2)