FDBRecordVersion implements Comparable<FDBRecordVersion> { @Nonnull public static FDBRecordVersion incomplete(int localVersion) { validateLocalVersion(localVersion); ByteBuffer buffer = ByteBuffer.allocate(VERSION_LENGTH).order(ByteOrder.BIG_ENDIAN); buffer.put(INCOMPLETE_GLOBAL_VERSION); buffer.putShort((short)localVersion); return new FDBRecordVersion(false, buffer.array(), false); } @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 incompleteBadLocalVersionLow() { assertThrows(RecordCoreException.class, () -> FDBRecordVersion.incomplete(-1)); }
@Test public void incompleteBadLocalVersionHigh() { assertThrows(RecordCoreException.class, () -> FDBRecordVersion.incomplete(0x10000)); }
@Test public void incomplete() { FDBRecordVersion v2 = FDBRecordVersion.incomplete(4); assertFalse(v2.isComplete()); assertThrows(FDBRecordVersion.IncompleteRecordVersionException.class, v2::getDBVersion); assertThrows(FDBRecordVersion.IncompleteRecordVersionException.class, v2::getGlobalVersion); assertEquals(4, v2.getLocalVersion()); }