Package com.io7m.coffeepick.runtime
Class RuntimeVersion
- java.lang.Object
-
- com.io7m.coffeepick.runtime.RuntimeVersion
-
- All Implemented Interfaces:
RuntimeVersionType,java.lang.Comparable<RuntimeVersionType>
public final class RuntimeVersion extends java.lang.Object implements RuntimeVersionType
A (slightly reduced) version number for Java runtimes. This version represents a subset of the possible data present in Java runtime versions. Specifically, this version number represents just the semantic versioning information, plus a build number.- See Also:
- "https://openjdk.java.net/jeps/223"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRuntimeVersion.BuilderBuilds instances of typeRuntimeVersion.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.math.BigInteger>build()static RuntimeVersion.Builderbuilder()Creates a builder forRuntimeVersion.static RuntimeVersioncopyOf(RuntimeVersionType instance)Creates an immutable copy of aRuntimeVersionTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofRuntimeVersionthat have equal attribute values.inthashCode()Computes a hash code from attributes:major,minor,patch,build.java.math.BigIntegermajor()java.math.BigIntegerminor()java.math.BigIntegerpatch()java.lang.StringtoString()Prints the immutable valueRuntimeVersionwith attribute values.RuntimeVersionwithBuild(java.math.BigInteger value)Copy the current immutable object by setting a present value for the optionalbuildattribute.RuntimeVersionwithBuild(java.util.Optional<? extends java.math.BigInteger> optional)Copy the current immutable object by setting an optional value for thebuildattribute.RuntimeVersionwithMajor(java.math.BigInteger value)Copy the current immutable object by setting a value for themajorattribute.RuntimeVersionwithMinor(java.math.BigInteger value)Copy the current immutable object by setting a value for theminorattribute.RuntimeVersionwithPatch(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, wait
-
Methods inherited from interface com.io7m.coffeepick.runtime.RuntimeVersionType
compareTo, toExternalMinimalString, toExternalString
-
-
-
-
Method Detail
-
major
public java.math.BigInteger major()
- Specified by:
majorin interfaceRuntimeVersionType- Returns:
- The major version
-
minor
public java.math.BigInteger minor()
- Specified by:
minorin interfaceRuntimeVersionType- Returns:
- The minor version
-
patch
public java.math.BigInteger patch()
- Specified by:
patchin interfaceRuntimeVersionType- Returns:
- The patch version
-
build
public java.util.Optional<java.math.BigInteger> build()
- Specified by:
buildin interfaceRuntimeVersionType- Returns:
- The build number, if any
-
withMajor
public final RuntimeVersion withMajor(java.math.BigInteger value)
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
public final RuntimeVersion withMinor(java.math.BigInteger value)
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
public final RuntimeVersion withPatch(java.math.BigInteger value)
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
-
withBuild
public final RuntimeVersion withBuild(java.math.BigInteger value)
Copy the current immutable object by setting a present value for the optionalbuildattribute.- Parameters:
value- The value for build- Returns:
- A modified copy of
thisobject
-
withBuild
public final RuntimeVersion withBuild(java.util.Optional<? extends java.math.BigInteger> optional)
Copy the current immutable object by setting an optional value for thebuildattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for build- Returns:
- A modified copy of
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofRuntimeVersionthat 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,build.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueRuntimeVersionwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
copyOf
public static RuntimeVersion copyOf(RuntimeVersionType instance)
Creates an immutable copy of aRuntimeVersionTypevalue. 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 RuntimeVersion instance
-
builder
public static RuntimeVersion.Builder builder()
Creates a builder forRuntimeVersion.RuntimeVersion.builder() .setMajor(java.math.BigInteger) // requiredmajor.setMinor(java.math.BigInteger) // requiredminor.setPatch(java.math.BigInteger) // requiredpatch.setBuild(java.math.BigInteger) // optionalbuild.build();- Returns:
- A new RuntimeVersion builder
-
-