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 class
RuntimeVersion.Builder
Builds instances of typeRuntimeVersion
. -
Method Summary
Modifier and Type Method Description java.util.Optional<java.math.BigInteger>
build()
static RuntimeVersion.Builder
builder()
Creates a builder forRuntimeVersion
.static RuntimeVersion
copyOf(RuntimeVersionType instance)
Creates an immutable copy of aRuntimeVersionType
value.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofRuntimeVersion
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:major
,minor
,patch
,build
.java.math.BigInteger
major()
java.math.BigInteger
minor()
java.math.BigInteger
patch()
java.lang.String
toString()
Prints the immutable valueRuntimeVersion
with attribute values.RuntimeVersion
withBuild(java.math.BigInteger value)
Copy the current immutable object by setting a present value for the optionalbuild
attribute.RuntimeVersion
withBuild(java.util.Optional<? extends java.math.BigInteger> optional)
Copy the current immutable object by setting an optional value for thebuild
attribute.RuntimeVersion
withMajor(java.math.BigInteger value)
Copy the current immutable object by setting a value for themajor
attribute.RuntimeVersion
withMinor(java.math.BigInteger value)
Copy the current immutable object by setting a value for theminor
attribute.RuntimeVersion
withPatch(java.math.BigInteger value)
Copy the current immutable object by setting a value for thepatch
attribute.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 Details
-
major
public java.math.BigInteger major()- Specified by:
major
in interfaceRuntimeVersionType
- Returns:
- The major version
-
minor
public java.math.BigInteger minor()- Specified by:
minor
in interfaceRuntimeVersionType
- Returns:
- The minor version
-
patch
public java.math.BigInteger patch()- Specified by:
patch
in interfaceRuntimeVersionType
- Returns:
- The patch version
-
build
public java.util.Optional<java.math.BigInteger> build()- Specified by:
build
in interfaceRuntimeVersionType
- Returns:
- The build number, if any
-
withMajor
Copy the current immutable object by setting a value for themajor
attribute. 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
this
object
-
withMinor
Copy the current immutable object by setting a value for theminor
attribute. 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
this
object
-
withPatch
Copy the current immutable object by setting a value for thepatch
attribute. 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
this
object
-
withBuild
Copy the current immutable object by setting a present value for the optionalbuild
attribute.- Parameters:
value
- The value for build- Returns:
- A modified copy of
this
object
-
withBuild
Copy the current immutable object by setting an optional value for thebuild
attribute. 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
this
object
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofRuntimeVersion
that have equal attribute values.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifthis
is equal toanother
instance
-
hashCode
public int hashCode()Computes a hash code from attributes:major
,minor
,patch
,build
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueRuntimeVersion
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aRuntimeVersionType
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 RuntimeVersion instance
-
builder
Creates a builder forRuntimeVersion
.RuntimeVersion.builder() .setMajor(java.math.BigInteger) // required
major
.setMinor(java.math.BigInteger) // requiredminor
.setPatch(java.math.BigInteger) // requiredpatch
.setBuild(java.math.BigInteger) // optionalbuild
.build();- Returns:
- A new RuntimeVersion builder
-