public boolean hasNext() { return fileLastRecordNumber.compareTo(recordNumber) > 0; }
public void testCompare() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); assertEquals( aUnsigned.bigIntegerValue().compareTo(bUnsigned.bigIntegerValue()), aUnsigned.compareTo(bUnsigned)); } } }
/** * Checks whatever extending a file from this offset with to a given length * will overflow NFS4_UINT64_MAX. * * @param length to verify * @param msg included into exception * @throws InvalException if offset + length will overflow * {@link Long.MAX_VALUE} */ public void checkOverflow(long length, String msg) throws InvalException { if (length == nfs4_prot.NFS4_UINT64_MAX) { // special case - up-to-the-end return; } if (MAX_UINT64.minus(UnsignedLong.fromLongBits(value)).compareTo(UnsignedLong.fromLongBits(length)) < 0) { throw new InvalException(msg); } } }
public void testCompare() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); assertEquals(aUnsigned.bigIntegerValue().compareTo(bUnsigned.bigIntegerValue()), aUnsigned.compareTo(bUnsigned)); } } }
@Override public ValueType<UnsignedLong> delta(Number value) { UnsignedLong previous = toUnsignedLong(value); // If previous value is greater-than this one, we've wrapped if (previous.compareTo(getValue()) > 0) { if (NAN_ON_COUNTER_WRAP) { throw new ArithmeticException(); } UnsignedLong count32 = getValue().plus(MAX32).plus(UnsignedLong.ONE); // Still smaller, this is a 64-bit counter wrap if (previous.compareTo(count32) > 0) { return new Counter(MAX64.minus(previous).plus(getValue()).plus(UnsignedLong.ONE)); } // Process as 32-bit counter wrap else { return new Counter(MAX32.minus(previous).plus(getValue())).plus(UnsignedLong.ONE); } } // ...no counter wrap has occurred. else { return new Counter(getValue().minus(previous)); } }