Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 2.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.fop.util
Class CompareUtil

    java.lang.Object
      org.apache.fop.util.CompareUtil

    public final class CompareUtil

extends java.lang.Object

A utility class that provides helper methods for implementing equals and hashCode.

Method Summary
`static boolean` | `equal(double n1, double n2)` Compares two numbers for equality.
`static boolean` | `equal(java.lang.Object o1, java.lang.Object o2)` Compares two objects for equality.
`static int` | `getHashCode(double number)` Returns a hash code for the given number.
`static int` | `getHashCode(java.lang.Object object)` Returns the hash code of the given object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### equal

    public static boolean equal(java.lang.Object o1,
                                java.lang.Object o2)

  Compares two objects for equality. In order to prevent lock-ordering deadlocks the following strategy is used: when two non null objects are passed to the method, the comparison is done by calling the `Object.equals(Object)` method of the object with the lower hash code (`System.identityHashCode(Object)`); in the rare case that two different objects have the same hash code, a lock is used.

  Parameters:
    `o1` - an object
    `o2` - another object
  Returns:
    true if either o1 and o2 are null or if o1.equals(o2)

### getHashCode

    public static int getHashCode(java.lang.Object object)

  Returns the hash code of the given object.

  Parameters:
    `object` - an object
  Returns:
    object.hashCode(), or 0 if object is null

### equal

    public static boolean equal(double n1,
                                double n2)

  Compares two numbers for equality. Uses the same comparison algorithm as the `Double.equals(Object)` method.

  Parameters:
    `n1` - a number
    `n2` - another number
  Returns:
    true if the two numbers are equal, false otherwise

### getHashCode

    public static int getHashCode(double number)

  Returns a hash code for the given number. Applies the same algorithm as the `Double.hashCode()` method.

  Parameters:
    `number` - a number
  Returns:
    a hash code for that number

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 2.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 1999-2017 The Apache Software Foundation. All Rights Reserved.