public final class RevisionVector extends Object implements Iterable<Revision>, Comparable<RevisionVector>, org.apache.jackrabbit.oak.cache.CacheValue
update(Revision) create a new instance as needed.
This class implements Comparable. While
compareTo(RevisionVector) provides a total order of revision
vector instances, this order is unrelated to when changes are visible in
a DocumentNodeStore cluster. Do not use this method to determine whether
a given revision vector happened before or after another!| Constructor and Description |
|---|
RevisionVector(@NotNull Iterable<Revision> revisions) |
RevisionVector(Revision... revisions) |
RevisionVector(@NotNull Set<Revision> revisions) |
| Modifier and Type | Method and Description |
|---|---|
RevisionVector |
asBranchRevision(int clusterId)
A clone of this revision vector with the revision for the given
clusterId set to a branch revision.
|
String |
asString()
Returns a string representation of this revision vector, which can be
parsed again by
fromString(String). |
RevisionVector |
asTrunkRevision()
Returns a revision vector where all revision elements are turned into
trunk revisions.
|
int |
compareTo(@NotNull RevisionVector other) |
RevisionVector |
difference(RevisionVector vector)
Returns the difference of this and the other vector.
|
boolean |
equals(Object o) |
static RevisionVector |
fromString(String s)
Creates a revision vector from a string representation as returned by
asString(). |
@NotNull Revision |
getBranchRevision() |
int |
getDimensions()
Returns the dimensions of this revision vector.
|
int |
getMemory() |
Revision |
getRevision(int clusterId)
Returns the revision element with the given clusterId or
null
if there is no such revision in this vector. |
int |
hashCode() |
boolean |
isBranch() |
boolean |
isRevisionNewer(@NotNull Revision revision)
Returns
true if the given revision is newer than the revision
element with the same clusterId in the vector. |
Iterator<Revision> |
iterator() |
RevisionVector |
pmax(@NotNull RevisionVector vector)
Calculates the parallel maximum of this and the given
vector. |
RevisionVector |
pmin(@NotNull RevisionVector vector)
Calculates the parallel minimum of this and the given
vector. |
RevisionVector |
remove(int clusterId)
Returns a RevisionVector without the revision element with the given
clusterId. |
String |
toString() |
StringBuilder |
toStringBuilder(StringBuilder sb)
Appends the string representation of this revision vector to the passed
StringBuilder. |
RevisionVector |
update(@NotNull Revision revision)
Creates a new revision vector with based on this vector and the given
revision. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic RevisionVector(@NotNull
Revision... revisions)
public RevisionVector update(@NotNull @NotNull Revision revision)
revision. If this vector contains a revision with the same
clusterId as revision, the returned vector will have the
revision updated with the given one. Otherwise the returned vector will
have all elements of this vector plus the given revision.revision - the revision set to use for the new vector.public RevisionVector remove(int clusterId)
clusterId.clusterId - the clusterId of the revision to remove.public RevisionVector pmin(@NotNull @NotNull RevisionVector vector)
vector.vector - the other vector.public RevisionVector pmax(@NotNull @NotNull RevisionVector vector)
vector.vector - the other vector.public RevisionVector difference(RevisionVector vector)
vector - the other vector.public boolean isRevisionNewer(@NotNull
@NotNull Revision revision)
true if the given revision is newer than the revision
element with the same clusterId in the vector. The given revision is
also considered newer if there is no revision element with the same
clusterId in this vector.revision - the revision to check.true if considered newer, false otherwise.public boolean isBranch()
true if any of the revisions in this vector is a branch
revision, false otherwise.@NotNull public @NotNull Revision getBranchRevision()
IllegalStateException - if this vector does not contain a branch
revision.public Revision getRevision(int clusterId)
null
if there is no such revision in this vector.clusterId - a clusterId.null
if none exists.public String asString()
fromString(String).public StringBuilder toStringBuilder(StringBuilder sb)
StringBuilder. The string representation is the same as returned
by asString().sb - the StringBuilder this revision vector is appended to.StringBuilder object.public static RevisionVector fromString(String s)
asString().s - the string representation of a revision vector.IllegalArgumentException - if the string is malformedpublic RevisionVector asTrunkRevision()
public RevisionVector asBranchRevision(int clusterId)
clusterId - the clusterId of the revision to be turned into a branch
revision.IllegalArgumentException - if there is no revision element with the
given clusterId.public int getDimensions()
public int getMemory()
getMemory in interface org.apache.jackrabbit.oak.cache.CacheValuepublic int compareTo(@NotNull
@NotNull RevisionVector other)
compareTo in interface Comparable<RevisionVector>Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.