Package megamek.common.board
Record Class BoardDimensions
java.lang.Object
java.lang.Record
megamek.common.board.BoardDimensions
- All Implemented Interfaces:
Serializable,Comparable<BoardDimensions>
public record BoardDimensions(int w, int h)
extends Record
implements Serializable, Comparable<BoardDimensions>
Type-safe, immutable, dimensions class for handling board sizes.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCompares BoardDimensions based on width, falling back on height if the widths are equalbooleanIndicates whether some other object is "equal to" this one.inth()Returns the value of thehrecord component.final inthashCode()Returns a hash code value for this object.intheight()longnumHexes()toString()Returns a string representation of this record class.intw()Returns the value of thewrecord component.intwidth()
-
Constructor Details
-
BoardDimensions
public BoardDimensions(int w, int h) Construct a new BoardDimensions object.- Parameters:
w- The widthh- The height- Throws:
IllegalArgumentException- If either width or height is less than 1.
-
-
Method Details
-
width
public int width()- Returns:
- The board width.
-
height
public int height()- Returns:
- The board height.
-
numHexes
public long numHexes()- Returns:
- The total number of hexes in the board.
-
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 '=='. -
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. -
compareTo
Compares BoardDimensions based on width, falling back on height if the widths are equal- Specified by:
compareToin interfaceComparable<BoardDimensions>
-
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. -
w
public int w()Returns the value of thewrecord component.- Returns:
- the value of the
wrecord component
-
h
public int h()Returns the value of thehrecord component.- Returns:
- the value of the
hrecord component
-