Documentation of 'math.utils.EqualUtils' Java class
EqualUtils
math.utils

Class EqualUtils



  • public final class EqualUtils
    extends java.lang.Object
    Collected methods which allow easy implementation of equals. Rewritten from http://www.javapractices.com/topic/TopicAction.do?Id=17. Example use case in a class called Car:
    public boolean equals(Object aThat){
      if ( this == aThat ) return true;
      if ( !(aThat instanceof Car) ) return false;
      Car that = (Car)aThat;
      return
        EqualsUtil.areEqual(this.name, that.name) &&
        EqualsUtil.areEqual(this.numDoors, that.numDoors) &&
        EqualsUtil.areEqual(this.gasMileage, that.gasMileage) &&
        EqualsUtil.areEqual(this.color, that.color) &&
        Arrays.equals(this.maintenanceChecks, that.maintenanceChecks); //array!
    }
     
    Arrays are not handled by this class. This is because the Arrays.equals methods should be used for array fields.
    • Constructor Summary

      Constructors 
      Constructor and Description
      EqualUtils() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static boolean areEqual(boolean aThis, boolean aThat) 
      static boolean areEqual(char aThis, char aThat) 
      static boolean areEqual(double aThis, double aThat) 
      static boolean areEqual(float aThis, float aThat) 
      static boolean areEqual(long aThis, long aThat) 
      static boolean areEqual(java.lang.Object aThis, java.lang.Object aThat)
      Possibly-null object field.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EqualUtils

        public EqualUtils()
    • Method Detail

      • areEqual

        public static boolean areEqual(boolean aThis,
                                       boolean aThat)
      • areEqual

        public static boolean areEqual(char aThis,
                                       char aThat)
      • areEqual

        public static boolean areEqual(long aThis,
                                       long aThat)
      • areEqual

        public static boolean areEqual(float aThis,
                                       float aThat)
      • areEqual

        public static boolean areEqual(double aThis,
                                       double aThat)
      • areEqual

        public static boolean areEqual(java.lang.Object aThis,
                                       java.lang.Object aThat)
        Possibly-null object field. Includes type-safe enumerations and collections, but does not include arrays. See class comment.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.