public int compareTo(Item item) { if (item == null) { return BigInteger_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } switch (item.getType()) { case INTEGER_ITEM: return value.compareTo(((IntegerItem) item).value); case STRING_ITEM: return 1; // 1.1 > 1-sp case LIST_ITEM: return 1; // 1.1 > 1-1 default: throw new RuntimeException("invalid item: " + item.getClass()); } }
public int compareTo(Item item) { if (item == null) { // 1-rc < 1, 1-ga > 1 return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX); } switch (item.getType()) { case INTEGER_ITEM: return -1; // 1.any < 1.1 ? case STRING_ITEM: return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value)); case LIST_ITEM: return -1; // 1.any < 1-1 default: throw new RuntimeException("invalid item: " + item.getClass()); } }
public int compareTo(Item item) { if (item == null) { if (size() == 0) { return 0; // 1-0 = 1- (normalize) = 1 } Item first = get(0); return first.compareTo(null); } switch (item.getType()) { case INTEGER_ITEM: return -1; // 1-1 < 1.0.x case STRING_ITEM: return 1; // 1-1 > 1-sp case LIST_ITEM: Iterator<Item> left = iterator(); Iterator<Item> right = ((ListItem) item).iterator(); while (left.hasNext() || right.hasNext()) { Item l = left.hasNext() ? left.next() : null; Item r = right.hasNext() ? right.next() : null; // if this is shorter, then invert the compare and mul with -1 int result = l == null ? -1 * r.compareTo(l) : l.compareTo(r); if (result != 0) { return result; } } return 0; default: throw new RuntimeException("invalid item: " + item.getClass()); } }
public int compareTo(Item item) { if (item == null) { if (size() == 0) { return 0; // 1-0 = 1- (normalize) = 1 } Item first = get(0); return first.compareTo(null); } switch (item.getType()) { case INTEGER_ITEM: return -1; // 1-1 < 1.0.x case STRING_ITEM: return 1; // 1-1 > 1-sp case LIST_ITEM: Iterator<Item> left = iterator(); Iterator<Item> right = ((ListItem) item).iterator(); while (left.hasNext() || right.hasNext()) { Item l = left.hasNext() ? left.next() : null; Item r = right.hasNext() ? right.next() : null; // if this is shorter, then invert the compare and mul with -1 int result = l == null ? -1 * r.compareTo(l) : l.compareTo(r); if (result != 0) { return result; } } return 0; default: throw new RuntimeException("invalid item: " + item.getClass()); } }
public int compareTo(Item item) { if (item == null) { // 1-rc < 1, 1-ga > 1 return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX); } switch (item.getType()) { case INTEGER_ITEM: return -1; // 1.any < 1.1 ? case STRING_ITEM: return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value)); case LIST_ITEM: return -1; // 1.any < 1-1 default: throw new RuntimeException("invalid item: " + item.getClass()); } }
public int compareTo(Item item) { if (item == null) { return BigInteger_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } switch (item.getType()) { case INTEGER_ITEM: return value.compareTo(((IntegerItem) item).value); case STRING_ITEM: return 1; // 1.1 > 1-sp case LIST_ITEM: return 1; // 1.1 > 1-1 default: throw new RuntimeException("invalid item: " + item.getClass()); } }