PropertyStateValue implements PropertyValue { @Override public int compareTo(@NotNull PropertyValue p2) { if (getType().tag() != p2.getType().tag()) { return Integer.signum(p2.getType().tag() - getType().tag()); } switch (getType().tag()) { case PropertyType.BOOLEAN: return compare(getValue(Type.BOOLEANS), p2.getValue(Type.BOOLEANS)); case PropertyType.DECIMAL: return compare(getValue(Type.DECIMALS), p2.getValue(Type.DECIMALS)); case PropertyType.DOUBLE: return compare(getValue(Type.DOUBLES), p2.getValue(Type.DOUBLES)); case PropertyType.LONG: return compare(getValue(Type.LONGS), p2.getValue(Type.LONGS)); case PropertyType.BINARY: return compareBinaries( getValue(Type.BINARIES), p2.getValue(Type.BINARIES)); case PropertyType.DATE: return compareAsDate( getValue(Type.STRINGS), p2.getValue(Type.STRINGS)); default: return compare(getValue(Type.STRINGS), p2.getValue(Type.STRINGS)); } } PropertyStateValue(PropertyState ps); @Override boolean isArray(); @Override @NotNull Type<?> getType(); @Override @NotNull T getValue(Type<T> type); @Override @NotNull T getValue(Type<T> type, int index); @Override long size(); @Override long size(int index); @Override int count(); @Nullable PropertyState unwrap(); @Override int compareTo(@NotNull PropertyValue p2); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }
@Test public void compareDates() { Calendar d1, d2; PropertyValue v1, v2; d1 = newCal(null); d2 = newCal(d1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertEquals("v1 and v2 should be equals", 0, v1.compareTo(v2)); assertEquals("v1 and v2 should be equals", 0, v2.compareTo(v1)); d1 = newCal(null); d2 = newCal(d1, GMT, 1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 < v2", v1.compareTo(v2) < 0); assertTrue("v2 > v1", v2.compareTo(v1) > 0); d1 = newCal(null); d2 = newCal(d1, GMT, -1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 > v2", v1.compareTo(v2) > 0); assertTrue("v2 < v1", v2.compareTo(v1) < 0); d1 = newCal(null, PST, 0); d2 = newCal(d1, PST, 0); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertEquals("v1 and v2 should be equals", 0, v1.compareTo(v2)); assertEquals("v1 and v2 should be equals", 0, v2.compareTo(v1)); d1 = newCal(null, PST, 0); d2 = newCal(d1, PST, 1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 < v2", v1.compareTo(v2) < 0); assertTrue("v2 > v1", v2.compareTo(v1) > 0); d1 = newCal(null, PST, 0); d2 = newCal(d1, PST, -1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 > v2", v1.compareTo(v2) > 0); assertTrue("v2 < v1", v2.compareTo(v1) < 0); d1 = newCal(null); d2 = newCal(d1, CET, 0); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertEquals("v1 and v2 should be equals", 0, v1.compareTo(v2)); assertEquals("v1 and v2 should be equals", 0, v2.compareTo(v1)); d1 = newCal(null); d2 = newCal(d1, CET, 1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 < v2", v1.compareTo(v2) < 0); assertTrue("v2 > v1", v2.compareTo(v1) > 0); d1 = newCal(null); d2 = newCal(d1, CET, -1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 > v2", v1.compareTo(v2) > 0); assertTrue("v2 < v1", v2.compareTo(v1) < 0); d1 = newCal(null); d2 = newCal(d1, PST, 0); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertEquals("v1 and v2 should be equals", 0, v1.compareTo(v2)); assertEquals("v1 and v2 should be equals", 0, v2.compareTo(v1)); d1 = newCal(null); d2 = newCal(d1, PST, 1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 < v2", v1.compareTo(v2) < 0); assertTrue("v2 > v1", v2.compareTo(v1) > 0); d1 = newCal(null); d2 = newCal(d1, PST, -1); v1 = newDate(format(d1)); v2 = newDate(format(d2)); assertTrue("v1 > v2", v1.compareTo(v2) > 0); assertTrue("v2 < v1", v2.compareTo(v1) < 0); }