Record Class Move

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
  • Constructor Details

    • Move

      public Move(Move.Square from, Move.Square to, Move.PromotionPiece promotionPiece)
      Creates an instance of a Move record class.
      Parameters:
      from - the value for the from record component
      to - the value for the to record component
      promotionPiece - the value for the promotionPiece record component
  • Method Details

    • of

      public static Move of(Move.Square from, Move.Square to)
    • of

      public static Move of(Move.Square from, Move.Square to, Move.PromotionPiece promotionPiece)
    • of

      public static Move of(String moveStr)
    • toString

      public String 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
      Specified by:
      toString in class Record
      Returns:
      the string representation of the move
    • equals

      public 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 Objects::equals(Object,Object).
      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.
    • 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
    • from

      public Move.Square from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public Move.Square to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • promotionPiece

      public Move.PromotionPiece promotionPiece()
      Returns the value of the promotionPiece record component.
      Returns:
      the value of the promotionPiece record component