Record Class AreaSize

java.lang.Object
java.lang.Record
net.apartium.cocoabeans.space.AreaSize
Record Components:
width - the width of the area
height - the height of the area
depth - the depth of the area

@AvailableSince("0.0.46") public record AreaSize(double width, double height, double depth) extends Record
Represents the size of a 3D area with width, height, and depth.

Provides utility methods for creating cubic areas, flooring dimensions, converting to regions, and calculating the volume as an integer.

Since:
0.0.46
  • Constructor Summary

    Constructors
    Constructor
    Description
    AreaSize(double width, double height, double depth)
    Creates an instance of a AreaSize record class.
    Constructs a new AreaSize by copying another AreaSize.
  • Method Summary

    Modifier and Type
    Method
    Description
    static AreaSize
    box(double length)
    Creates a cubic AreaSize with all sides equal to the given length.
    double
    Returns the value of the depth record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns a new AreaSize with each dimension floored to the nearest integer.
    final int
    Returns a hash code value for this object.
    double
    Returns the value of the height record component.
    int
    Calculates the volume of the area as an integer, flooring each dimension first.
    final String
    Returns a string representation of this record class.
    double
    Returns the value of the width record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AreaSize

      public AreaSize(AreaSize size)
      Constructs a new AreaSize by copying another AreaSize.
      Parameters:
      size - the AreaSize to copy
    • AreaSize

      public AreaSize(double width, double height, double depth)
      Creates an instance of a AreaSize record class.
      Parameters:
      width - the value for the width record component
      height - the value for the height record component
      depth - the value for the depth record component
  • Method Details

    • box

      public static AreaSize box(double length)
      Creates a cubic AreaSize with all sides equal to the given length.
      Parameters:
      length - the length of each side
      Returns:
      a new AreaSize with equal width, height, and depth
    • floor

      public AreaSize floor()
      Returns a new AreaSize with each dimension floored to the nearest integer.
      Returns:
      a new AreaSize with floored dimensions
    • toAreaSize

      public int toAreaSize()
      Calculates the volume of the area as an integer, flooring each dimension first.
      Returns:
      the volume as an integer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • width

      public double width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public double height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component
    • depth

      public double depth()
      Returns the value of the depth record component.
      Returns:
      the value of the depth record component