Package com.io7m.changelog.core
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 classCVersion.BuilderBuilds instances of typeCVersion. -
Method Summary
Modifier and Type Method Description static CVersion.Builderbuilder()Creates a builder forCVersion.static CVersioncopyOf(CVersionType instance)Creates an immutable copy of aCVersionTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofCVersionthat have equal attribute values.inthashCode()Computes a hash code from attributes:major,minor,patch.java.math.BigIntegermajor()java.math.BigIntegerminor()static CVersionof(java.math.BigInteger major, java.math.BigInteger minor, java.math.BigInteger patch)Construct a new immutableCVersioninstance.java.math.BigIntegerpatch()java.lang.StringtoString()Prints the immutable valueCVersionwith attribute values.CVersionwithMajor(java.math.BigInteger value)Copy the current immutable object by setting a value for themajorattribute.CVersionwithMinor(java.math.BigInteger value)Copy the current immutable object by setting a value for theminorattribute.CVersionwithPatch(java.math.BigInteger value)Copy the current immutable object by setting a value for thepatchattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.io7m.changelog.core.CVersionType
checkPreconditions, compareTo, formatTo
-
Method Details
-
major
public java.math.BigInteger major()- Specified by:
majorin interfaceCVersionType- Returns:
- The value of the
majorattribute
-
minor
public java.math.BigInteger minor()- Specified by:
minorin interfaceCVersionType- Returns:
- The value of the
minorattribute
-
patch
public java.math.BigInteger patch()- Specified by:
patchin interfaceCVersionType- Returns:
- The value of the
patchattribute
-
withMajor
Copy the current immutable object by setting a value for themajorattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for major- Returns:
- A modified copy of the
thisobject
-
withMinor
Copy the current immutable object by setting a value for theminorattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for minor- Returns:
- A modified copy of the
thisobject
-
withPatch
Copy the current immutable object by setting a value for thepatchattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for patch- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofCVersionthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()Computes a hash code from attributes:major,minor,patch.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueCVersionwith attribute values.- Overrides:
toStringin classjava.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 immutableCVersioninstance.- Parameters:
major- The value for themajorattributeminor- The value for theminorattributepatch- The value for thepatchattribute- Returns:
- An immutable CVersion instance
-
copyOf
Creates an immutable copy of aCVersionTypevalue. 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
Creates a builder forCVersion.CVersion.builder() .setMajor(java.math.BigInteger) // requiredmajor.setMinor(java.math.BigInteger) // requiredminor.setPatch(java.math.BigInteger) // requiredpatch.build();- Returns:
- A new CVersion builder
-