@Test public void complete() { FDBRecordVersion v1 = FDBRecordVersion.complete(VERSION_BYTES_ONE, 5); assertTrue(v1.isComplete()); assertEquals(1066L, v1.getDBVersion()); assertArrayEquals(VERSION_BYTES_ONE, v1.getGlobalVersion()); assertEquals(5, v1.getLocalVersion()); FDBRecordVersion v2 = FDBRecordVersion.complete(VERSION_BYTES_FOUR); assertTrue(v2.isComplete()); assertEquals(1776L, v2.getDBVersion()); assertArrayEquals(Arrays.copyOfRange(VERSION_BYTES_FOUR, 0, 10), v2.getGlobalVersion()); assertEquals(0, v2.getLocalVersion()); FDBRecordVersion v3 = FDBRecordVersion.complete(VERSION_BYTES_FIVE); assertTrue(v3.isComplete()); assertEquals(1776L, v3.getDBVersion()); assertArrayEquals(Arrays.copyOfRange(VERSION_BYTES_FIVE, 0, 10), v3.getGlobalVersion()); assertEquals(0xffff, v3.getLocalVersion()); }
@Nonnull public static FDBRecordVersion complete(@Nonnull byte[] globalVersion, int localVersion) { if (globalVersion.length != GLOBAL_VERSION_LENGTH) { throw new RecordCoreException("Specified global version has invalid length " + globalVersion.length); } if (Arrays.equals(INCOMPLETE_GLOBAL_VERSION, globalVersion)) { throw new RecordCoreException("Specified version has incomplete global version"); } validateLocalVersion(localVersion); ByteBuffer buffer = ByteBuffer.allocate(VERSION_LENGTH).order(ByteOrder.BIG_ENDIAN); buffer.put(globalVersion); buffer.putShort((short)localVersion); return new FDBRecordVersion(true, buffer.array(), false); }
FDBRecordVersion implements Comparable<FDBRecordVersion> { @Nonnull public static FDBRecordVersion complete(@Nonnull byte[] globalVersion, int localVersion) { if (globalVersion.length != GLOBAL_VERSION_LENGTH) { throw new RecordCoreException("Specified global version has invalid length " + globalVersion.length); } if (Arrays.equals(INCOMPLETE_GLOBAL_VERSION, globalVersion)) { throw new RecordCoreException("Specified version has incomplete global version"); } validateLocalVersion(localVersion); ByteBuffer buffer = ByteBuffer.allocate(VERSION_LENGTH).order(ByteOrder.BIG_ENDIAN); buffer.put(globalVersion); buffer.putShort((short)localVersion); return new FDBRecordVersion(true, buffer.array(), false); } }
FDBRecordVersion implements Comparable<FDBRecordVersion> { @Nonnull public static FDBRecordVersion complete(@Nonnull byte[] globalVersion, int localVersion) { if (globalVersion.length != GLOBAL_VERSION_LENGTH) { throw new RecordCoreException("Specified global version has invalid length " + globalVersion.length); } if (Arrays.equals(INCOMPLETE_GLOBAL_VERSION, globalVersion)) { throw new RecordCoreException("Specified version has incomplete global version"); } validateLocalVersion(localVersion); ByteBuffer buffer = ByteBuffer.allocate(VERSION_LENGTH).order(ByteOrder.BIG_ENDIAN); buffer.put(globalVersion); buffer.putShort((short)localVersion); return new FDBRecordVersion(true, buffer.array(), false); } @Nonnull private  FDBRecordVersion(boolean complete, @Nonnull byte[] versionBytes, boolean copy); }
FDBRecordVersion implements Comparable<FDBRecordVersion> { @Nonnull public static FDBRecordVersion complete(@Nonnull byte[] globalVersion, int localVersion) { if (globalVersion.length != GLOBAL_VERSION_LENGTH) { throw new RecordCoreException("Specified global version has invalid length " + globalVersion.length); } if (Arrays.equals(INCOMPLETE_GLOBAL_VERSION, globalVersion)) { throw new RecordCoreException("Specified version has incomplete global version"); } validateLocalVersion(localVersion); ByteBuffer buffer = ByteBuffer.allocate(VERSION_LENGTH).order(ByteOrder.BIG_ENDIAN); buffer.put(globalVersion); buffer.putShort((short)localVersion); return new FDBRecordVersion(true, 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(); }
FDBRecordVersion implements Comparable<FDBRecordVersion> { @Nonnull public static FDBRecordVersion complete(@Nonnull byte[] globalVersion, int localVersion) { if (globalVersion.length != GLOBAL_VERSION_LENGTH) { throw new RecordCoreException("Specified global version has invalid length " + globalVersion.length); } if (Arrays.equals(INCOMPLETE_GLOBAL_VERSION, globalVersion)) { throw new RecordCoreException("Specified version has incomplete global version"); } validateLocalVersion(localVersion); ByteBuffer buffer = ByteBuffer.allocate(VERSION_LENGTH).order(ByteOrder.BIG_ENDIAN); buffer.put(globalVersion); buffer.putShort((short)localVersion); return new FDBRecordVersion(true, 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; }