EqualUtils
math.utils

Class EqualUtils



  • public final class EqualUtilsextends 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 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(Object aThis,               Object aThat)
        Possibly-null object field. Includes type-safe enumerations and collections, but does not include arrays. See class comment.

SCaVis 2.2 © jWork.ORG