# com.beasys.commerce.foundation
SmartComparator Class

public class SmartComparator
extends `Object`
implements `Comparator`, `Serializable`

This is an implementation of the Comparator Interface that compares two objects. It is useful when building and searching maps and lists of Business Smart Components (BSC). As an example, all belongings, SmartKeys and SmartHandles are comparable. It uses the singleton pattern

Hierarchy
  `Object`
  `SmartComparator`

All Implemented Interfaces
  `Comparator`, `Serializable`

## Method Summary

  `public int` | `compare`(`Object` o1, `Object` o2) The compare method compares the following types:
       String
       Comparable
If the objects neither String or Comparable, then it compares the String representation of the objects.
`public static `SmartComparator`` | `getInstance`()

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

Methods from interface `java.util.`Comparator``
`compare, equals`

## Method Detail

### compare(Object, Object) Method

    public int compare(Object o1,
                       Object o2)

The compare method compares the following types:

     String
     Comparable

If the objects neither String or Comparable, then it compares the String representation of the objects. Note: o1 and o2 must be have the same type.

#### Parameters

o1
  object 1 to compare

o2
  object 2 to compare

#### Returns

(o1 == o2) ? 0 : (o1 < 02) ? -1 : 1

### getInstance() Method

    public static SmartComparator getInstance()