Record Class SpriteSheetInfo

java.lang.Object
java.lang.Record
technology.sola.engine.assets.graphics.spritesheet.SpriteSheetInfo
Record Components:
spriteSheet - the path to the spritesheet's image
sprites - the SpriteInfo definitions within the spritesheet

@NullMarked public record SpriteSheetInfo(String spriteSheet, List<SpriteInfo> sprites) extends Record
Contains information about a spritesheet.
  • Constructor Details

    • SpriteSheetInfo

      public SpriteSheetInfo(String spriteSheet, List<SpriteInfo> sprites)
      Creates an instance of a SpriteSheetInfo record class.
      Parameters:
      spriteSheet - the value for the spriteSheet record component
      sprites - the value for the sprites record component
  • Method Details

    • addSprite

      public SpriteSheetInfo addSprite(SpriteInfo newSpriteInfo)
      Adds a new sprite to the sprite sheet and returns a new instance.
      Parameters:
      newSpriteInfo - the SpriteInfo of the new sprite
      Returns:
      a new SpriteSheetInfo instance with the sprite added
    • updateSprite

      public SpriteSheetInfo updateSprite(String id, SpriteInfo newSpriteInfo)
      Updates a sprite by id and returns a new instance.
      Parameters:
      id - the id of the sprite to update
      newSpriteInfo - the new SpriteInfo for the sprite
      Returns:
      a new SpriteSheetInfo instance with the sprite updated
    • removeSprite

      public SpriteSheetInfo removeSprite(String id)
      Removes a sprite by its id from this sprite sheet and returns a new instance.
      Parameters:
      id - the id of the sprite to remove
      Returns:
      a new SpriteSheetInfo instance with the sprite removed
    • 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.
    • spriteSheet

      public String spriteSheet()
      Returns the value of the spriteSheet record component.
      Returns:
      the value of the spriteSheet record component
    • sprites

      public List<SpriteInfo> sprites()
      Returns the value of the sprites record component.
      Returns:
      the value of the sprites record component