Record Class ConventionalCommit

java.lang.Object
java.lang.Record
io.github.joke.conventionalversion.calc.ConventionalCommit
Record Components:
type - the commit type, or null when the header does not conform
scope - the optional scope; captured but not yet used to derive per-module versions
breaking - whether the commit declares a breaking change
releaseAs - the version named by a Release-As: footer, or null

public record ConventionalCommit(@Nullable String type, @Nullable String scope, boolean breaking, @Nullable SemanticVersion releaseAs) extends Record
A single commit reduced to the facts that affect the version.

A message that does not conform to the Conventional Commits specification is represented with a null type rather than by an exception, because a repository is free to contain any commit message and an unparseable one simply contributes nothing.

  • Constructor Details

    • ConventionalCommit

      public ConventionalCommit(@Nullable String type, @Nullable String scope, boolean breaking, @Nullable SemanticVersion releaseAs)
      Creates an instance of a ConventionalCommit record class.
      Parameters:
      type - the value for the type record component
      scope - the value for the scope record component
      breaking - the value for the breaking record component
      releaseAs - the value for the releaseAs record component
  • Method Details

    • nonConforming

      public static ConventionalCommit nonConforming()
      A message that conforms to nothing and names no version.
    • findType

      public Optional<String> findType()
    • findReleaseAs

      public Optional<SemanticVersion> findReleaseAs()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public @Nullable String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • scope

      public @Nullable String scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component
    • breaking

      public boolean breaking()
      Returns the value of the breaking record component.
      Returns:
      the value of the breaking record component
    • releaseAs

      public @Nullable SemanticVersion releaseAs()
      Returns the value of the releaseAs record component.
      Returns:
      the value of the releaseAs record component