@PublicApi @Immutable public class DataVersion extends Object
DataVersion
is used to identify whether some content has changed and to
support incremental updates. It contains two numbers:
The code that observes VersionedDataSource
would typically store last received
DataVersion
and use it next time in VersionedDataSource.getUpdate(DataVersion)
.
The code that implements VersionedDataSource
, would typically increment version
when an incremental update happens and reinitialize signature
when non-incremental update
happens.
Two instances of DataVersion
can be compared — we can tell which one happened
before which, but only if their signatures match.
VersionedDataSource
,
ForestSource
Modifier and Type | Field and Description |
---|---|
static DataVersion |
ZERO |
Constructor and Description |
---|
DataVersion(int signature,
int version)
Constructs
DataVersion . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
getSignature()
Signature defines the identity of the version sequence.
|
int |
getVersion()
Returns the version within one sequence, identified by signature
|
int |
hashCode() |
DataVersion |
increment()
Creates a new
DataVersion with version incremented by 1. |
DataVersion |
increment(int count)
Creates a new
DataVersion with version incremented by the specified amount. |
boolean |
isBefore(DataVersion anotherVersion)
Returns
true if this version is "before" the given version, that is, it has the same signature
and lower version. |
boolean |
isComparable(DataVersion anotherVersion)
Returns
true if this version can be compared to the specified version (that is possible only if
their signatures match) |
String |
toString() |
public static final DataVersion ZERO
public DataVersion(int signature, int version)
DataVersion
.public boolean isComparable(@Nullable DataVersion anotherVersion)
true
if this version can be compared to the specified version (that is possible only if
their signatures match)public boolean isBefore(@Nullable DataVersion anotherVersion)
true
if this version is "before" the given version, that is, it has the same signature
and lower version.public DataVersion increment()
DataVersion
with version incremented by 1.public DataVersion increment(int count)
DataVersion
with version incremented by the specified amount.public int getSignature()
public int getVersion()
Copyright © 2024 Tempo Software. All Rights Reserved.