java.lang.Object
java.lang.Record
net.chesstango.gardel.move.Move
public record Move(Move.Square from, Move.Square to, Move.PromotionPiece promotionPiece)
extends Record
Represents a chess move in pure algebraic notation.
This record encapsulates the essential parts of a chess move: the source square,
destination square, and an optional promotion piece for pawn promotions.
- Author:
- Mauricio Coria
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumRepresents the possible pieces a pawn can promote to in chess.static enumRepresents the squares on a chess board using standard algebraic notation. -
Constructor Summary
ConstructorsConstructorDescriptionMove(Move.Square from, Move.Square to, Move.PromotionPiece promotionPiece) Creates an instance of aMoverecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.from()Returns the value of thefromrecord component.final inthashCode()Returns a hash code value for this object.static Movestatic Moveof(Move.Square from, Move.Square to) static Moveof(Move.Square from, Move.Square to, Move.PromotionPiece promotionPiece) Returns the value of thepromotionPiecerecord component.to()Returns the value of thetorecord component.toString()Returns the string representation of the move in pure algebraic notation.
-
Constructor Details
-
Move
Creates an instance of aMoverecord class.- Parameters:
from- the value for thefromrecord componentto- the value for thetorecord componentpromotionPiece- the value for thepromotionPiecerecord component
-
-
Method Details
-
of
-
of
-
of
-
toString
Returns the string representation of the move in pure algebraic notation. Format: [from square][to square][promotion piece] Example: "e2e4" for a regular move, "e7e8q" for a promotion -
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 withObjects::equals(Object,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. -
from
Returns the value of thefromrecord component.- Returns:
- the value of the
fromrecord component
-
to
Returns the value of thetorecord component.- Returns:
- the value of the
torecord component
-
promotionPiece
Returns the value of thepromotionPiecerecord component.- Returns:
- the value of the
promotionPiecerecord component
-