Package net.apartium.cocoabeans.space
Record Class AreaSize
java.lang.Object
java.lang.Record
net.apartium.cocoabeans.space.AreaSize
- Record Components:
width- the width of the areaheight- the height of the areadepth- 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic AreaSizebox(double length) Creates a cubic AreaSize with all sides equal to the given length.doubledepth()Returns the value of thedepthrecord component.final booleanIndicates whether some other object is "equal to" this one.floor()Returns a new AreaSize with each dimension floored to the nearest integer.final inthashCode()Returns a hash code value for this object.doubleheight()Returns the value of theheightrecord component.intCalculates the volume of the area as an integer, flooring each dimension first.final StringtoString()Returns a string representation of this record class.doublewidth()Returns the value of thewidthrecord component.
-
Constructor Details
-
AreaSize
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 aAreaSizerecord class.
-
-
Method Details
-
box
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
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
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. -
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. -
equals
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 '=='. -
width
public double width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
height
public double height()Returns the value of theheightrecord component.- Returns:
- the value of the
heightrecord component
-
depth
public double depth()Returns the value of thedepthrecord component.- Returns:
- the value of the
depthrecord component
-