Enum Class GitDiffSegmentType

java.lang.Object
java.lang.Enum<GitDiffSegmentType>
com.atlassian.bitbucket.scm.git.command.diff.GitDiffSegmentType
All Implemented Interfaces:
Serializable, Comparable<GitDiffSegmentType>, Constable

public enum GitDiffSegmentType extends Enum<GitDiffSegmentType>
A git-specific extension of the general DiffSegmentType enumeration bound more tightly to standard diff core output.
  • Enum Constant Details

    • ADDED

      public static final GitDiffSegmentType ADDED
      A leading plus marks an added line.
    • COMMENT

      public static final GitDiffSegmentType COMMENT
      A leading backslash marks observations git offers about files it diffs. For example,
       
       \ No newline at end of file
       
       
      Note the space after the slash, which is included as part of this prefix.
    • CONTEXT

      public static final GitDiffSegmentType CONTEXT
      A leading space marks a context line.
    • REMOVED

      public static final GitDiffSegmentType REMOVED
      A leading hyphen marks a removed line.
  • Method Details

    • values

      public static GitDiffSegmentType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static GitDiffSegmentType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • forLine

      public static GitDiffSegmentType forLine(String line)
      Examines the provided line to determine its segment type. If the line does not start with a known prefix, null is returned (to indicate the line does not belong to a segment).
      Parameters:
      line - the line to examine
      Returns:
      the matching segment type, or null
    • dropPrefix

      public String dropPrefix(String line)
      Trims the prefix from the provided line. This helper function allows prefixes to be different lengths, which supports the COMMENT type.
      Parameters:
      line - the line to trim
      Returns:
      the trimmed line
    • getPrefix

      public String getPrefix()
      Retrieves the prefix which identifies this segment type.
      Returns:
      the prefix
    • getType

      public com.atlassian.bitbucket.content.DiffSegmentType getType()
      Retrieves the general DiffSegmentType for this git segment type.
      Returns:
      the associated general segment type
    • isValid

      public boolean isValid()