private static EnumSegment[] getEnumSegments(EnumDefinition ed) { EnumSegment[] values = enumDefinitionCache.get(ed); if (values == null) { int ordinal = ed.identifiers.length; values = new EnumSegment[ordinal]; while (--ordinal >= 0) values[ordinal] = new EnumSegment(ordinal, ed); enumDefinitionCache.put(ed, values); } return values; }
static void rawToString(StringBuffer sb, boolean forRange, Comparable<?> e) { if (e instanceof String) { writeQuotedString(sb, forRange, (String) e, '\'', 0, false); } else if (e instanceof VersionVector) { sb.append('<'); ((VersionVector) e).toString(sb, forRange); sb.append('>'); } else if (e instanceof EnumDefinition.EnumSegment) ((EnumDefinition.EnumSegment) e).toString(sb); else sb.append(e); }
static int compareSegments(Comparable<?> a, Comparable<?> b) { if (a == b) return 0; if (a instanceof Integer && b instanceof Integer) { int ai = ((Integer) a).intValue(); int bi = ((Integer) b).intValue(); return ai > bi ? 1 : (ai < bi ? -1 : 0); } if (a instanceof String && b instanceof String) return ((String) a).compareTo((String) b); if (a == MAX_VALUE || a == MIN_VALUE || a == MAXS_VALUE) return ((MinMaxComparable) a).compareTo(b); if (b == MAX_VALUE || b == MIN_VALUE || b == MAXS_VALUE) return -((MinMaxComparable) b).compareTo(a); if (a instanceof Integer) return 1; if (b instanceof Integer) return -1; if (a instanceof VersionVector) return (b instanceof VersionVector) ? ((VersionVector) a).compareTo((VersionVector) b) : 1; if (b instanceof VersionVector) return -1; if (a instanceof EnumDefinition.EnumSegment) return (b instanceof EnumDefinition.EnumSegment) ? ((EnumDefinition.EnumSegment) a).compareTo((EnumDefinition.EnumSegment) b) : 1; if (b instanceof EnumDefinition.EnumSegment) return -1; throw new IllegalArgumentException(); }
public boolean equals(Object other) { return other == this || other instanceof EnumSegment && compareTo((EnumSegment) other) == 0; }