private static <T> String toUnsignedString(T v) { if (v instanceof Byte) return intToUnsignedString(byteToUnsignedInt((Byte)v)); else if (v instanceof Short) return intToUnsignedString(shortToUnsignedInt((Short)v)); else if (v instanceof Integer) return intToUnsignedString((Integer)v); else if (v instanceof Long) return longToUnsignedString((Long)v); throw new IllegalArgumentException("Not Range of Byte,Short,Integer, or Long"+v.getClass()); }
public static String intToUnsignedString(int input) { return Long.toString(intToUnsignedLong(input)); }
public int compare(Integer v1, Integer v2) { return intCompareUnsigned(v1, v2); } public boolean equals(Object o2) { return o2==this; }
@Test public void testToUnsignedString() { testToStringUnsigned(Ranges.open((byte)0,(byte)255), "(0..255)"); testToStringUnsigned(Ranges.closed((byte)0,(byte)255), "[0..255]"); testToStringUnsigned(Ranges.open((short)0,(short)0xFFFF), "(0..65535)"); testToStringUnsigned(Ranges.open(0,0xFFFFFFFF), "(0.."+ intToUnsignedString(0xFFFFFFFF)+")"); testToStringUnsigned(Ranges.open(0L,0xFFFFFFFFFFFFFFFFL), "(0.."+longToUnsignedString(0xFFFFFFFFFFFFFFFFL)+")"); }
public int compare(Short v1, Short v2) { return intCompareUnsigned(shortToUnsignedInt(v1), shortToUnsignedInt(v2)); } public boolean equals(Object o2) { return o2==this; }
public int compare(Byte v1, Byte v2) { return intCompareUnsigned(byteToUnsignedInt(v1), byteToUnsignedInt(v2)); } public boolean equals(Object o2) { return o2==this; }
public int compare(Long v1, Long v2) { return longCompareUnsigned(v1, v2); } public boolean equals(Object o2) { return o2==this; }