Class Revision

  • All Implemented Interfaces:
    CacheValue

    public final class Revision
    extends java.lang.Object
    implements CacheValue
    A revision.
    • Constructor Summary

      Constructors 
      Constructor Description
      Revision​(long timestamp, int counter, int clusterId)  
      Revision​(long timestamp, int counter, int clusterId, boolean branch)  
    • Constructor Detail

      • Revision

        public Revision​(long timestamp,
                        int counter,
                        int clusterId)
      • Revision

        public Revision​(long timestamp,
                        int counter,
                        int clusterId,
                        boolean branch)
    • Method Detail

      • getCurrentTimestamp

        public static long getCurrentTimestamp()
        Get the timestamp value of the current date and time. Within the same process, the returned value is never smaller than a previously returned value, even if the system time was changed.
        Returns:
        the timestamp
      • getTimestampDifference

        public static long getTimestampDifference​(Revision r1,
                                                  Revision r2)
        Get the timestamp difference between two revisions (r1 - r2) in milliseconds.
        Parameters:
        r1 - the first revision
        r2 - the second revision
        Returns:
        the difference in milliseconds
      • fromString

        public static Revision fromString​(java.lang.String rev)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toStringBuilder

        public java.lang.StringBuilder toStringBuilder​(java.lang.StringBuilder sb)
        Appends the string representation of this revision to the given StringBuilder.
        Parameters:
        sb - a StringBuilder.
        Returns:
        the StringBuilder instance passed to this method.
      • toReadableString

        public java.lang.String toReadableString()
      • getTimestamp

        public long getTimestamp()
        Get the timestamp in milliseconds since 1970.
        Returns:
        the timestamp
      • getCounter

        public int getCounter()
      • isBranch

        public boolean isBranch()
        Returns:
        true if this is a branch revision, otherwise false.
      • asBranchRevision

        public Revision asBranchRevision()
        Returns a revision with the same timestamp, counter and clusterId as this revision and the branch flag set to true.
        Returns:
        branch revision with this timestamp, counter and clusterId.
      • asTrunkRevision

        public Revision asTrunkRevision()
        Returns a revision with the same timestamp, counter and clusterId as this revision and the branch flag set to false.
        Returns:
        trunk revision with this timestamp, counter and clusterId.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • getClusterId

        public int getClusterId()
      • getMemory

        public int getMemory()
        Description copied from interface: CacheValue
        The estimated amount of memory used by this object, in bytes.
        Specified by:
        getMemory in interface CacheValue
        Returns:
        the estimated number of bytes