Record Class GamevalRef

java.lang.Object
java.lang.Record
com.botwithus.bot.api.gameval.GamevalRef
Record Components:
type - namespace the name lives in
gameval - the symbolic name
fallbackId - the id to use when the name does not resolve; for GamevalType.COMPONENT the packed (interfaceId << 16) | componentId

public record GamevalRef(GamevalType type, String gameval, int fallbackId) extends Record
A gameval name paired with the id it resolved to when the calling code was written. Lets api facades address interfaces, components and variables by name — so a game renumber is fixed by refreshing the gameval index — while still working on a host with no index deployed.
static final GamevalRef ITEMS = new GamevalRef(GamevalType.COMPONENT, "BANK__BANK_INV",
        Interfaces.componentHash(517, 201));
int hash = ITEMS.resolve(api.gamevals());
  • Constructor Details

    • GamevalRef

      public GamevalRef(GamevalType type, String gameval, int fallbackId)
      Creates an instance of a GamevalRef record class.
      Parameters:
      type - the value for the type record component
      gameval - the value for the gameval record component
      fallbackId - the value for the fallbackId record component
  • Method Details

    • resolve

      public int resolve(GamevalIndex index)
      The id index resolves gameval() to, or fallbackId() when the name is unknown or no index is deployed.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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 GamevalType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • gameval

      public String gameval()
      Returns the value of the gameval record component.
      Returns:
      the value of the gameval record component
    • fallbackId

      public int fallbackId()
      Returns the value of the fallbackId record component.
      Returns:
      the value of the fallbackId record component