Class FormatVersion

java.lang.Object
com.io7m.coffeepick.runtime.parser.spi.FormatVersion
All Implemented Interfaces:
FormatVersionType, java.lang.Comparable<FormatVersionType>

public final class FormatVersion
extends java.lang.Object
implements FormatVersionType
A format version.
  • Method Details

    • major

      public int major()
      Specified by:
      major in interface FormatVersionType
      Returns:
      The major number for a format
    • minor

      public int minor()
      Specified by:
      minor in interface FormatVersionType
      Returns:
      The minor number for a format
    • withMajor

      public final FormatVersion withMajor​(int value)
      Copy the current immutable object by setting a value for the major attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for major
      Returns:
      A modified copy of the this object
    • withMinor

      public final FormatVersion withMinor​(int value)
      Copy the current immutable object by setting a value for the minor attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for minor
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals​(java.lang.Object another)
      This instance is equal to all instances of FormatVersion that have equal attribute values.
      Overrides:
      equals in class java.lang.Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: major, minor.
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      hashCode value
    • toString

      public java.lang.String toString()
      Prints the immutable value FormatVersion with attribute values.
      Overrides:
      toString in class java.lang.Object
      Returns:
      A string representation of the value
    • of

      public static FormatVersion of​(int major, int minor)
      Construct a new immutable FormatVersion instance.
      Parameters:
      major - The value for the major attribute
      minor - The value for the minor attribute
      Returns:
      An immutable FormatVersion instance
    • copyOf

      public static FormatVersion copyOf​(FormatVersionType instance)
      Creates an immutable copy of a FormatVersionType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable FormatVersion instance
    • builder

      public static FormatVersion.Builder builder()
      Creates a builder for FormatVersion.
       FormatVersion.builder()
          .setMajor(int) // required major
          .setMinor(int) // required minor
          .build();
       
      Returns:
      A new FormatVersion builder