java.lang.Object
com.io7m.jregions.core.parameterized.areas.PAreaI<S>
Type Parameters:
S - A phantom type parameter indicating the coordinate space of the area
All Implemented Interfaces:
PAreaIType<S>, AreaValuesIType, AreaSizeValuesIType

public final class PAreaI<S> extends Object implements PAreaIType<S>

An area with int coordinates.

The coordinates of the area are given in half-closed form. That is, minimumX() refers to the minimum inclusive value on the X axis, and maximumX() refers to the maximum exclusive value on the X axis. Likewise for the Y axis.

  • Method Details

    • width

      @Deprecated public int width()
      Deprecated.
      Specified by:
      width in interface AreaSizeValuesIType
      Returns:
      The width of the area
    • height

      @Deprecated public int height()
      Deprecated.
      Specified by:
      height in interface AreaSizeValuesIType
      Returns:
      The height of the area
    • minimumX

      public int minimumX()
      Specified by:
      minimumX in interface AreaValuesIType
      Specified by:
      minimumX in interface PAreaIType<S>
      Returns:
      The value of the minimumX attribute
    • maximumX

      public int maximumX()
      Specified by:
      maximumX in interface AreaValuesIType
      Specified by:
      maximumX in interface PAreaIType<S>
      Returns:
      The value of the maximumX attribute
    • minimumY

      public int minimumY()
      Specified by:
      minimumY in interface AreaValuesIType
      Specified by:
      minimumY in interface PAreaIType<S>
      Returns:
      The value of the minimumY attribute
    • maximumY

      public int maximumY()
      Specified by:
      maximumY in interface AreaValuesIType
      Specified by:
      maximumY in interface PAreaIType<S>
      Returns:
      The value of the maximumY attribute
    • withMinimumX

      public final PAreaI<S> withMinimumX(int value)
      Copy the current immutable object by setting a value for the minimumX attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for minimumX
      Returns:
      A modified copy of the this object
    • withMaximumX

      public final PAreaI<S> withMaximumX(int value)
      Copy the current immutable object by setting a value for the maximumX attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for maximumX
      Returns:
      A modified copy of the this object
    • withMinimumY

      public final PAreaI<S> withMinimumY(int value)
      Copy the current immutable object by setting a value for the minimumY attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for minimumY
      Returns:
      A modified copy of the this object
    • withMaximumY

      public final PAreaI<S> withMaximumY(int value)
      Copy the current immutable object by setting a value for the maximumY attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for maximumY
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of PAreaI that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: minimumX, maximumX, minimumY, maximumY.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static <S> PAreaI<S> of(int minimumX, int maximumX, int minimumY, int maximumY)
      Construct a new immutable PAreaI instance.
      Type Parameters:
      S - generic parameter S
      Parameters:
      minimumX - The value for the minimumX attribute
      maximumX - The value for the maximumX attribute
      minimumY - The value for the minimumY attribute
      maximumY - The value for the maximumY attribute
      Returns:
      An immutable PAreaI instance
    • copyOf

      public static <S> PAreaI<S> copyOf(PAreaIType<S> instance)
      Creates an immutable copy of a PAreaIType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Type Parameters:
      S - generic parameter S
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable PAreaI instance
    • builder

      public static <S> PAreaI.Builder<S> builder()
      Creates a builder for PAreaI.
       PAreaI.&lt;S&gt;builder()
          .setMinimumX(int) // required minimumX
          .setMaximumX(int) // required maximumX
          .setMinimumY(int) // required minimumY
          .setMaximumY(int) // required maximumY
          .build();
       
      Type Parameters:
      S - generic parameter S
      Returns:
      A new PAreaI builder