}
@Override
public int compare( CardinalitySpec a, CardinalitySpec b ) {
PathElement ape = a.pathElement;
PathElement bpe = b.pathElement;
int aa = orderMap.get( ape.getClass() );
int bb = orderMap.get( bpe.getClass() );
int elementsEqual = aa < bb ? -1 : aa == bb ? 0 : 1;
if ( elementsEqual != 0 ) {
return elementsEqual;
}
// At this point we have two PathElements of the same type.
String acf = ape.getCanonicalForm();
String bcf = bpe.getCanonicalForm();
int alen = acf.length();
int blen = bcf.length();
// Sort them by length, with the longest (most specific) being first