Class DataVersion
Object
DataVersion
DataVersion is used to identify whether some content has changed and to
support incremental updates. It contains two numbers:
- signature, which is a randomly chosen value that defines the "namespace" for the second number, and
- version, which is a number that is incremented every time an update to the data happens.
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.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintSignature defines the identity of the version sequence.intReturns the version within one sequence, identified by signatureinthashCode()Creates a newDataVersionwith version incremented by 1.increment(int count) Creates a newDataVersionwith version incremented by the specified amount.booleanisBefore(DataVersion anotherVersion) Returnstrueif this version is "before" the given version, that is, it has the same signature and lower version.booleanisComparable(DataVersion anotherVersion) Returnstrueif this version can be compared to the specified version (that is possible only if their signatures match)toString()
-
Field Details
-
ZERO
-
-
Constructor Details
-
DataVersion
public DataVersion(int signature, int version) ConstructsDataVersion.
-
-
Method Details
-
isComparable
Returnstrueif this version can be compared to the specified version (that is possible only if their signatures match) -
isBefore
Returnstrueif this version is "before" the given version, that is, it has the same signature and lower version. -
increment
Creates a newDataVersionwith version incremented by 1. -
increment
Creates a newDataVersionwith version incremented by the specified amount. -
getSignature
public int getSignature()Signature defines the identity of the version sequence. Only versions within the same signature can be compared.- Returns:
- the signature of the version sequence
-
getVersion
public int getVersion()Returns the version within one sequence, identified by signature -
toString
-
equals
-
hashCode
public int hashCode()
-