Record Class SavedWorldObject

java.lang.Object
java.lang.Record
za.co.wethinkcode.robots.server.persistence.SavedWorldObject
Record Components:
type - the persisted object type
topLeft - the object's top-left position
bottomRight - the object's bottom-right position
mineType - the mine type when type is MINE; otherwise null

public record SavedWorldObject(SavedWorldObjectType type, Position topLeft, Position bottomRight, MineType mineType) extends Record
Represents an immutable static world object that can be persisted.
  • Constructor Details

    • SavedWorldObject

      public SavedWorldObject(SavedWorldObjectType type, Position topLeft, Position bottomRight)
      Creates a persisted obstacle or pit without mine information.
      Parameters:
      type - the persisted object type
      topLeft - the object's top-left position
      bottomRight - the object's bottom-right position
    • SavedWorldObject

      public SavedWorldObject(SavedWorldObjectType type, Position topLeft, Position bottomRight, MineType mineType)
      Creates an instance of a SavedWorldObject record class.
      Parameters:
      type - the value for the type record component
      topLeft - the value for the topLeft record component
      bottomRight - the value for the bottomRight record component
      mineType - the value for the mineType record component
  • Method Details

    • 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 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.
    • type

      public SavedWorldObjectType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • topLeft

      public Position topLeft()
      Returns the value of the topLeft record component.
      Returns:
      the value of the topLeft record component
    • bottomRight

      public Position bottomRight()
      Returns the value of the bottomRight record component.
      Returns:
      the value of the bottomRight record component
    • mineType

      public MineType mineType()
      Returns the value of the mineType record component.
      Returns:
      the value of the mineType record component