Package com.io7m.waxmill.machines
Class WXMMemory
java.lang.Object
com.io7m.waxmill.machines.WXMMemory
- All Implemented Interfaces:
WXMMemoryType
public final class WXMMemory extends java.lang.Object implements WXMMemoryType
The specification of the size of a virtual machine's memory. This
is specified as a number of megabytes
m plus a number of gigabytes
g, where m >= 0 ∧ g >= 0.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWXMMemory.BuilderBuilds instances of typeWXMMemory. -
Method Summary
Modifier and Type Method Description static WXMMemory.Builderbuilder()Creates a builder forWXMMemory.java.lang.Stringcomment()static WXMMemorycopyOf(WXMMemoryType instance)Creates an immutable copy of aWXMMemoryTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofWXMMemorythat have equal attribute values.java.math.BigIntegergigabytes()inthashCode()Computes a hash code from attributes:megabytes,gigabytes,comment.java.math.BigIntegermegabytes()java.lang.StringtoString()Prints the immutable valueWXMMemorywith attribute values.WXMMemorywithComment(java.lang.String value)Copy the current immutable object by setting a value for thecommentattribute.WXMMemorywithGigabytes(java.math.BigInteger value)Copy the current immutable object by setting a value for thegigabytesattribute.WXMMemorywithMegabytes(java.math.BigInteger value)Copy the current immutable object by setting a value for themegabytesattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.io7m.waxmill.machines.WXMMemoryType
checkPreconditions, totalBytes, totalMegabytes
-
Method Details
-
megabytes
public java.math.BigInteger megabytes()- Specified by:
megabytesin interfaceWXMMemoryType- Returns:
- The number of megabytes
-
gigabytes
public java.math.BigInteger gigabytes()- Specified by:
gigabytesin interfaceWXMMemoryType- Returns:
- The number of gigabytes
-
comment
public java.lang.String comment()- Specified by:
commentin interfaceWXMMemoryType- Returns:
- A descriptive comment
-
withMegabytes
Copy the current immutable object by setting a value for themegabytesattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for megabytes- Returns:
- A modified copy of the
thisobject
-
withGigabytes
Copy the current immutable object by setting a value for thegigabytesattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for gigabytes- Returns:
- A modified copy of the
thisobject
-
withComment
Copy the current immutable object by setting a value for thecommentattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for comment- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofWXMMemorythat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()Computes a hash code from attributes:megabytes,gigabytes,comment.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueWXMMemorywith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aWXMMemoryTypevalue. 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 WXMMemory instance
-
builder
Creates a builder forWXMMemory.WXMMemory.builder() .setMegabytes(java.math.BigInteger) // optionalmegabytes.setGigabytes(java.math.BigInteger) // optionalgigabytes.setComment(String) // optionalcomment.build();- Returns:
- A new WXMMemory builder
-