Class CVersion

java.lang.Object
com.io7m.changelog.core.CVersion
All Implemented Interfaces:
CVersionType, java.lang.Comparable<CVersionType>, java.util.Formattable

public final class CVersion
extends java.lang.Object
implements CVersionType
Immutable implementation of CVersionType.

Use the builder to create immutable instances: CVersion.builder(). Use the static factory method to create immutable instances: CVersion.of().

  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  CVersion.Builder
    Builds instances of type CVersion.
  • Method Summary

    Modifier and Type Method Description
    static CVersion.Builder builder()
    Creates a builder for CVersion.
    static CVersion copyOf​(CVersionType instance)
    Creates an immutable copy of a CVersionType value.
    boolean equals​(java.lang.Object another)
    This instance is equal to all instances of CVersion that have equal attribute values.
    int hashCode()
    Computes a hash code from attributes: major, minor, patch.
    java.math.BigInteger major()  
    java.math.BigInteger minor()  
    static CVersion of​(java.math.BigInteger major, java.math.BigInteger minor, java.math.BigInteger patch)
    Construct a new immutable CVersion instance.
    java.math.BigInteger patch()  
    java.lang.String toString()
    Prints the immutable value CVersion with attribute values.
    CVersion withMajor​(java.math.BigInteger value)
    Copy the current immutable object by setting a value for the major attribute.
    CVersion withMinor​(java.math.BigInteger value)
    Copy the current immutable object by setting a value for the minor attribute.
    CVersion withPatch​(java.math.BigInteger value)
    Copy the current immutable object by setting a value for the patch attribute.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.io7m.changelog.core.CVersionType

    checkPreconditions, compareTo, formatTo
  • Method Details

    • major

      public java.math.BigInteger major()
      Specified by:
      major in interface CVersionType
      Returns:
      The value of the major attribute
    • minor

      public java.math.BigInteger minor()
      Specified by:
      minor in interface CVersionType
      Returns:
      The value of the minor attribute
    • patch

      public java.math.BigInteger patch()
      Specified by:
      patch in interface CVersionType
      Returns:
      The value of the patch attribute
    • withMajor

      public final CVersion withMajor​(java.math.BigInteger value)
      Copy the current immutable object by setting a value for the major attribute. An equals check 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 CVersion withMinor​(java.math.BigInteger value)
      Copy the current immutable object by setting a value for the minor attribute. An equals check 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
    • withPatch

      public final CVersion withPatch​(java.math.BigInteger value)
      Copy the current immutable object by setting a value for the patch attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for patch
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals​(java.lang.Object another)
      This instance is equal to all instances of CVersion 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, patch.
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      hashCode value
    • toString

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

      public static CVersion of​(java.math.BigInteger major, java.math.BigInteger minor, java.math.BigInteger patch)
      Construct a new immutable CVersion instance.
      Parameters:
      major - The value for the major attribute
      minor - The value for the minor attribute
      patch - The value for the patch attribute
      Returns:
      An immutable CVersion instance
    • copyOf

      public static CVersion copyOf​(CVersionType instance)
      Creates an immutable copy of a CVersionType 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 CVersion instance
    • builder

      public static CVersion.Builder builder()
      Creates a builder for CVersion.
       CVersion.builder()
          .setMajor(java.math.BigInteger) // required major
          .setMinor(java.math.BigInteger) // required minor
          .setPatch(java.math.BigInteger) // required patch
          .build();
       
      Returns:
      A new CVersion builder