FDBRecordVersion implements Comparable<FDBRecordVersion> { @Nonnull public FDBRecordVersion next() { if (isComplete()) { byte[] newVersionBytes = Arrays.copyOf(versionBytes, VERSION_LENGTH); boolean stopped = false; for (int i = newVersionBytes.length - 1; i >= 0; i--) { if (((int) newVersionBytes[i] & 0xff) == 0xff) { newVersionBytes[i] = 0x00; } else { newVersionBytes[i] = (byte) (((int) newVersionBytes[i] & 0xff) + 1); stopped = true; break; } } if (!stopped || !isGlobalVersionComplete(newVersionBytes)) { throw new RecordCoreException("Attempted to increment maximum version"); } return FDBRecordVersion.complete(newVersionBytes, false); } else { return FDBRecordVersion.incomplete(getLocalVersion() + 1); } } @Nonnull private  FDBRecordVersion(boolean complete, @Nonnull byte[] versionBytes, boolean copy); @Nonnull static FDBRecordVersion complete(@Nonnull byte[] globalVersion, int localVersion); @Nonnull static FDBRecordVersion complete(@Nonnull byte[] versionBytes); @Nonnull static FDBRecordVersion complete(@Nonnull byte[] versionBytes, boolean copy); @Nonnull static FDBRecordVersion incomplete(int localVersion); @Nonnull static FDBRecordVersion fromBytes(@Nonnull byte[] versionBytes); @Nonnull static FDBRecordVersion fromBytes(@Nonnull byte[] versionBytes, boolean copy); @Nonnull static FDBRecordVersion fromVersionstamp(@Nonnull Versionstamp versionstamp); @Nonnull static FDBRecordVersion fromVersionstamp(@Nonnull Versionstamp versionstamp, boolean copy); @Nonnull static FDBRecordVersion firstInDBVersion(long dbVersion); static FDBRecordVersion firstInGlobalVersion(@Nonnull byte[] globalVersion); static FDBRecordVersion lastInDBVersion(long dbVersion); static FDBRecordVersion lastInGlobalVersion(@Nonnull byte[] globalVersion); @Nonnull Versionstamp toVersionstamp(); @Nonnull Versionstamp toVersionstamp(boolean copy); @Nonnull byte[] toBytes(); @Nonnull @SpotBugsSuppressWarnings(value = "EI", justification = "option is explicitly set to do this") byte[] toBytes(boolean copy); @Nonnull ByteBuffer writeTo(@Nonnull ByteBuffer buffer); int writeTo(@Nonnull byte[] bytes); int writeTo(@Nonnull byte[] bytes, int offset); boolean isComplete(); int getLocalVersion(); @Nonnull @SpotBugsSuppressWarnings(value = "EI", justification = "not mutated later") byte[] getGlobalVersion(); long getDBVersion(); @Nonnull FDBRecordVersion next(); @Nonnull FDBRecordVersion prev(); @Nonnull FDBRecordVersion withCommittedVersion(@Nullable byte[] committedVersion); @Override boolean equals(Object o); @Override int compareTo(@Nonnull FDBRecordVersion other); @Override int hashCode(); @Override @Nonnull String toString(); static final int GLOBAL_VERSION_LENGTH; static final int VERSION_LENGTH; static final FDBRecordVersion MIN_VERSION; static final FDBRecordVersion MAX_VERSION; }
@Test public void nextAfterMax() { assertThrows(RecordCoreException.class, () -> FDBRecordVersion.MAX_VERSION.next()); }