Record Class Item

java.lang.Object
java.lang.Record
de.chojo.universalis.entities.Item
Record Components:
id - id
name - name

public record Item(int id, Name name) extends Record
Represents an item. Includes localised names.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Item(int id, Name name)
    Creates an instance of a Item record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Item
    build(NameSupplier nameSupplier, int id)
    Creates an item based on an id and retrieves the names vie the supplier
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    int
    id()
    Returns the value of the id record component.
    Returns the value of the name record component.
    static Item
    ofId(int id)
    Create a new item by id with an empty name
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Item

      public Item(int id, Name name)
      Creates an instance of a Item record class.
      Parameters:
      id - the value for the id record component
      name - the value for the name record component
  • Method Details

    • build

      public static Item build(NameSupplier nameSupplier, int id)
      Creates an item based on an id and retrieves the names vie the supplier
      Parameters:
      nameSupplier - name supplier
      id - item id
      Returns:
      item
    • ofId

      public static Item ofId(int id)
      Create a new item by id with an empty name
      Parameters:
      id - id
      Returns:
      new item instance
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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 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
    • 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
    • id

      public int id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • name

      public Name name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component