Record Class QuirkEntry

java.lang.Object
java.lang.Record
megamek.common.QuirkEntry
Record Components:
code - The code (OptionsConstants.*) of this quirk. Not the display name.
value - Optional value for quirks that require parameters (e.g., "2750" for obsolete quirk). Empty for boolean quirks.
location - The location String ("LA", "FR" etc.) of this weapon quirk. Empty for unit quirks.
slot - The slot (0 - 11) of this weapon quirk. -1 for unit quirks
weaponName - The weapon internal name (e.g. CLERLargeLaser) of this weapon quirk. Empty for unit quirks. The weapon's name.

public record QuirkEntry(String code, String value, String location, int slot, String weaponName) extends Record
Class to store pertinent quirk information. This class is immutable.
  • Constructor Details

    • QuirkEntry

      public QuirkEntry(String quirkString)
      Creates a unit quirk entry from a string that may contain a value (e.g., "obsolete:2750" or just "command_mek"). The code should be a quirk code such as OptionsConstants.QUIRK_POS_COMMAND_MEK. The code may not be null or empty but is not otherwise checked if it is a valid value.
      Parameters:
      quirkString - The quirk string, optionally with a colon-separated value (e.g., "obsolete:2750")
    • QuirkEntry

      public QuirkEntry(String code, String value)
      Creates a unit quirk entry with a specific code and value.
      Parameters:
      code - The quirk code
      value - The quirk value (empty string for boolean quirks)
    • QuirkEntry

      public QuirkEntry(String code, String location, int slot, String weaponName)
      Use this constructor for building weapon quirks.
      Parameters:
      code - The quirk being created.
      location - The weapon's location (RT, LL, FF, LW, etc.)
      slot - The critical slot number (0-based) of the weapon's first critical.
      weaponName - The MegaMek name for the weapon (i.e. ISERLargeLaser)
    • QuirkEntry

      public QuirkEntry(String code, String value, String location, int slot, String weaponName)
      Canonical constructor for weapon quirks and full specification.
  • Method Details

    • location

      public String location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component
    • getQuirk

      public String getQuirk()
      Returns:
      The code (OptionsConstants.*) of this quirk. Not useful as a display name.
    • slot

      public int slot()
      Returns the value of the slot record component.
      Returns:
      the value of the slot record component
    • weaponName

      public String weaponName()
      Returns the value of the weaponName record component.
      Returns:
      the value of the weaponName record component
    • equals

      public boolean equals(Object obj)
      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:
      obj - the object with which to compare
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • hasValue

      public boolean hasValue()
      Returns:
      true if this quirk has a value (e.g., obsolete:2750), false for boolean quirks
    • isWeaponQuirk

      public boolean isWeaponQuirk()
    • toString

      @Nonnull public 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
    • code

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

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