Class Revision

java.lang.Object
com.linecorp.centraldogma.common.Revision
All Implemented Interfaces:
Comparable<Revision>

public class Revision extends Object implements Comparable<Revision>
A revision number of a Commit.

A revision number is an integer which refers to a specific point of repository history. When a repository is created, it starts with an initial commit whose revision is 1. As new commits are added, each commit gets its own revision number, monotonically increasing from the previous commit's revision. i.e. 1, 2, 3, ...

A revision number can also be represented as a negative integer. When a revision number is negative, we start from -1 which refers to the latest commit in repository history, which is often called 'HEAD' of the repository. A smaller revision number refers to the older commit. e.g. -2 refers to the commit before the latest commit, and so on.

A revision with a negative integer is called 'relative revision'. By contrast, a revision with a positive integer is called 'absolute revision'.

  • Field Details

    • INIT

      public static final Revision INIT
      Revision 1, also known as 'INIT'.
  • Constructor Details

    • Revision

      public Revision(int major)
      Creates a new instance with the specified revision number.
    • Revision

      @Deprecated public Revision(int major, int minor)
      Deprecated.
      Use Revision(int) instead. Minor revisions are not used anymore.
      Creates a new instance.
    • Revision

      public Revision(String revisionStr)
      Create a new instance from a string representation. e.g. "42", "-1"
  • Method Details

    • major

      public int major()
      Returns the revision number.
    • minor

      @Deprecated public int minor()
      Deprecated.
      Do not use. Minor revisions are not used anymore.
      Returns 0.
    • text

      public String text()
      Returns the textual representation of the revision. e.g. "42", "-1".
    • onMainLane

      @Deprecated public boolean onMainLane()
      Deprecated.
      Do not use. Minor revisions are not used anymore.
      Returns true.
    • backward

      public Revision backward(int count)
      Returns a new Revision whose revision number is earlier than this Revision.
      Parameters:
      count - the number of commits to go backward
    • forward

      public Revision forward(int count)
      Returns a new Revision whose revision number is later than this Revision.
      Parameters:
      count - the number of commits to go forward
    • hashCode

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

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Revision o)
      Specified by:
      compareTo in interface Comparable<Revision>
    • isRelative

      public boolean isRelative()
      Returns whether this Revision is relative.