Class MultiComparison
public final class MultiComparison implements Comparison
{
// Constructors
public MultiComparison(Comparison comparisons[]);
public MultiComparison(Comparison comparisonA,
Comparison comparisonB);
// Methods
public int compare(Object p, Object q);
}
This class provides a comparison based on an array of other comparisons. It enables you to specify a group of comparisons to be applied in priority order. The constructor takes an array of Comparison objects. When requested to perform a comparison of two objects through the compare method, the first comparison in the array is applied; if that comparison finds they are equal, the next comparison is called. This continues until either a comparison finds the objects to be different, or all comparisons have been called.
public MultiComparison(Comparison comparisons[]);
Constructs a new MultiComparison object with the specified comparison array.
| Parameter | Description |
| comparisons
| An array of Comparison objects.
|
public MultiComparison(Comparison comparisonA, Comparison comparisonB);
Constructs a new MultiComparison object with the specified comparisons.
| Parameter | Description |
| comparisonA
| The first Comparison object in the comparison array.
|
| comparisonB
| The second Comparison object in the comparison array.
|
public int compare(Object p, Object q);
Compares the two objects according to the comparison array. The comparison terminates when one of the comparisons in the array determines that the objects are different.
Return Value:
Returns the result of the comparison.
| Parameter | Description |
| p
| The first object to compare.
|
| q
| The second object to compare.
|