01: package org.andromda.utils.beans.comparators;
02:
03: import java.io.Serializable;
04:
05: import java.util.Comparator;
06:
07: /**
08: * Used to sort Boolean values
09: *
10: * @author Chad Brandon
11: */
12: class BooleanComparator implements Comparator, Serializable {
13: /**
14: * Used to sort Boolean values, both objects are assumed
15: * to be Boolean instances.
16: */
17: public int compare(Object objectA, Object objectB) {
18: Boolean aAsBoolean = (Boolean) objectA;
19: Boolean bAsBoolean = (Boolean) objectB;
20: int result = 0;
21: if (aAsBoolean.booleanValue() && !bAsBoolean.booleanValue()) {
22: result = 1;
23: } else if (!aAsBoolean.booleanValue()
24: && bAsBoolean.booleanValue()) {
25: result = -1;
26: }
27: return result;
28: }
29: }
|