mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
05.30.2009 e677a52916063439a3adc5b8517aff4a759fff88
Improve the comparison code of the class BaseDNDescriptor.
1 files modified
56 ■■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java 56 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.datamodel;
@@ -141,6 +141,28 @@
    {
      BaseDNDescriptor desc = (BaseDNDescriptor)o;
      returnValue = desc.getDn().compareTo(getDn());
      if (returnValue == 0)
      {
        returnValue = getType().compareTo(desc.getType());
      }
      if (returnValue == 0)
      {
        getBackend().getBackendID().compareTo(
            desc.getBackend().getBackendID());
      }
      if (returnValue == 0)
      {
        returnValue = compare(getEntries(), desc.getEntries());
      }
      if (returnValue == 0)
      {
        returnValue = compare(getAgeOfOldestMissingChange(),
            desc.getAgeOfOldestMissingChange());
      }
      if (returnValue == 0)
      {
        returnValue = compare(getMissingChanges(), desc.getMissingChanges());
      }
    }
    return returnValue;
  }
@@ -281,4 +303,36 @@
          getDn() +
        getBackend().getBackendID() + getMissingChanges()).hashCode();
  }
  private int compare(int i1, int i2)
  {
    if (i1 == i2)
    {
      return 0;
    }
    else if (i1 > i2)
    {
      return 1;
    }
    else
    {
      return -1;
    }
  }
  private int compare(long i1, long i2)
  {
    if (i1 == i2)
    {
      return 0;
    }
    else if (i1 > i2)
    {
      return 1;
    }
    else
    {
      return -1;
    }
  }
}