Record Class IdentityMappings

java.lang.Object
java.lang.Record
com.viaversion.viaversion.api.data.IdentityMappings
All Implemented Interfaces:
Mappings

public record IdentityMappings(int size, int mappedSize) extends Record implements Mappings
  • Constructor Summary

    Constructors
    Constructor
    Description
    IdentityMappings(int size, int mappedSize)
    Creates an instance of a IdentityMappings record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    getNewId(int id)
    Returns the mapped id from the given id, or -1 if invalid/out of bounds.
    final int
    Returns a hash code value for this object.
    Mappings with keys and values swapped.
    int
    Returns the value of the mappedSize record component.
    void
    setNewId(int id, int mappedId)
    Manually maps a specific id.
    int
    Returns the value of the size record component.
    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

    Methods inherited from interface com.viaversion.viaversion.api.data.Mappings

    contains, getNewIdOrDefault
  • Constructor Details

    • IdentityMappings

      public IdentityMappings(int size, int mappedSize)
      Creates an instance of a IdentityMappings record class.
      Parameters:
      size - the value for the size record component
      mappedSize - the value for the mappedSize record component
  • Method Details

    • getNewId

      public int getNewId(int id)
      Description copied from interface: Mappings
      Returns the mapped id from the given id, or -1 if invalid/out of bounds.
      Specified by:
      getNewId in interface Mappings
      Parameters:
      id - unmapped id
      Returns:
      mapped id, or -1 if invalid/out of bounds
    • setNewId

      public void setNewId(int id, int mappedId)
      Description copied from interface: Mappings
      Manually maps a specific id.
      Specified by:
      setNewId in interface Mappings
      Parameters:
      id - unmapped id
      mappedId - mapped id
    • inverse

      public Mappings inverse()
      Description copied from interface: Mappings
      Mappings with keys and values swapped.
      Specified by:
      inverse in interface Mappings
      Returns:
      mappings with keys and values swapped
    • 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 '=='.
      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.
    • size

      public int size()
      Returns the value of the size record component.
      Specified by:
      size in interface Mappings
      Returns:
      the value of the size record component
    • mappedSize

      public int mappedSize()
      Returns the value of the mappedSize record component.
      Specified by:
      mappedSize in interface Mappings
      Returns:
      the value of the mappedSize record component