Record Class BFSSpecial
java.lang.Object
java.lang.Record
megamek.common.battlefieldSupport.BFSSpecial
- Record Components:
code- the Special's abbreviation as authored (nevernull; blank is tolerated but not expected)value- the Special's parameter, ornullif it has none
- All Implemented Interfaces:
Serializable
A single Special ability on a Battlefield Support Asset, stored as an abbreviated code plus an optional parameter
value. The value is a String so it can hold either a number (for Specials like
IF2, APC1,
ECM6) or a type token (for Artillery (LT)).
On the Asset card, a numeric value is appended directly to the code (for example IF2) while a non-numeric
value is shown in parentheses (for example Artillery (LT)); Specials without a value are shown as-is (for
example TAG, No Turret).
Any code may be stored here, including ones this build does not implement: unknown Specials are preserved verbatim
and printed on the card, but ignored during gameplay. Recognized codes can be resolved to a BFSSpecialType
via knownType().
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBFSSpecial(String code, String value) Creates an instance of aBFSSpecialrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanbooleanhasValue()intValue()booleanisKnown()static BFSSpecialstatic BFSSpecialstatic BFSSpecialstatic BFSSpecialParses a card display token into aBFSSpecial.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
of
- Parameters:
code- the Special's abbreviation- Returns:
- a Special with no value
-
of
- Parameters:
code- the Special's abbreviationvalue- the Special's parameter- Returns:
- a Special with the given code and value
-
of
- Parameters:
code- the Special's abbreviationvalue- the Special's integer parameter- Returns:
- a Special with the given code and value
-
hasValue
public boolean hasValue()- Returns:
- true if this Special has a parameter value
-
hasNumericValue
public boolean hasNumericValue()- Returns:
- true if this Special's value is present and purely numeric
-
intValue
- Returns:
- the Special's value parsed as an integer, or empty if it is absent or non-numeric
-
knownType
- Returns:
- the known-Special registry entry for this code, if it is recognized
-
isKnown
public boolean isKnown()- Returns:
- true if this Special's code is recognized in the
BFSSpecialTyperegistry
-
displayString
- Returns:
- the card display form: the code with a numeric value appended (for example
IF2), a non-numeric value in parentheses (for exampleArtillery (LT)), or just the code when there is no value
-
parse
Parses a card display token into aBFSSpecial. Handles three forms: a parenthesized value (for exampleArtillery (LT)yields codeArtillery, valueLT); a trailing run of digits (for exampleIF2yields codeIF, value2); or no value (for exampleNo Turret,TAG).- Parameters:
token- the token to parse- Returns:
- the parsed Special, or
nullif the token isnullor blank
-
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. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
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
-