Package megamek.common
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 quirksweaponName- 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 Summary
ConstructorsConstructorDescriptionQuirkEntry(String quirkString) Creates a unit quirk entry from a string that may contain a value (e.g., "obsolete:2750" or just "command_mek").QuirkEntry(String code, String value) Creates a unit quirk entry with a specific code and value.QuirkEntry(String code, String location, int slot, String weaponName) Use this constructor for building weapon quirks.QuirkEntry(String code, String value, String location, int slot, String weaponName) Canonical constructor for weapon quirks and full specification. -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.booleanIndicates whether some other object is "equal to" this one.getQuirk()final inthashCode()Returns a hash code value for this object.booleanhasValue()booleanlocation()Returns the value of thelocationrecord component.intslot()Returns the value of theslotrecord component.toString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.Returns the value of theweaponNamerecord component.
-
Constructor Details
-
QuirkEntry
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 asOptionsConstants.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
Creates a unit quirk entry with a specific code and value.- Parameters:
code- The quirk codevalue- The quirk value (empty string for boolean quirks)
-
QuirkEntry
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
Canonical constructor for weapon quirks and full specification.
-
-
Method Details
-
location
Returns the value of thelocationrecord component.- Returns:
- the value of the
locationrecord component
-
getQuirk
- Returns:
- The code (OptionsConstants.*) of this quirk. Not useful as a display name.
-
slot
public int slot()Returns the value of theslotrecord component.- Returns:
- the value of the
slotrecord component
-
weaponName
Returns the value of theweaponNamerecord component.- Returns:
- the value of the
weaponNamerecord component
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
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
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. -
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. -
code
Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-