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.
  • Method Details

    • megabytes

      public java.math.BigInteger megabytes()
      Specified by:
      megabytes in interface WXMMemoryType
      Returns:
      The number of megabytes
    • gigabytes

      public java.math.BigInteger gigabytes()
      Specified by:
      gigabytes in interface WXMMemoryType
      Returns:
      The number of gigabytes
    • comment

      public java.lang.String comment()
      Specified by:
      comment in interface WXMMemoryType
      Returns:
      A descriptive comment
    • withMegabytes

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

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

      public final WXMMemory withComment​(java.lang.String value)
      Copy the current immutable object by setting a value for the comment attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for comment
      Returns:
      A modified copy of the this object
    • equals

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

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

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

      public static WXMMemory.Builder builder()
      Creates a builder for WXMMemory.
       WXMMemory.builder()
          .setMegabytes(java.math.BigInteger) // optional megabytes
          .setGigabytes(java.math.BigInteger) // optional gigabytes
          .setComment(String) // optional comment
          .build();
       
      Returns:
      A new WXMMemory builder