Package megamek.common.equipment
Class EquipmentBitSet
java.lang.Object
megamek.common.equipment.EquipmentBitSet
Represents a set of flags that can be used to represent the type and special properties of the equipment.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.EquipmentBitSet(EquipmentBitSet other) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionand(EquipmentFlag... flags) Returns a new empty EquipmentBitSet and the flags set if it is set in this EquipmentBitSet.andNot(EquipmentFlag flag) Returns a copy of this EquipmentBitSet with the flag cleared.voidclear()Clears all flags in the EquipmentBitSet.voidclear(EquipmentFlag flag) Clears the flag in the EquipmentBitSet.booleancontains(EquipmentBitSet other) booleanbooleanget(EquipmentFlag flag) Returns true if the flag is set in the EquipmentBitSet.<T extends Enum<T> & EquipmentFlag>
List<String> getSetFlagNames(Class<T> flagEnum) Returns a list of string names for all flags that are set in this EquipmentBitSet.<T extends Enum<T> & EquipmentFlag>
String[]getSetFlagNamesAsArray(Class<T> flagEnum) Returns an array of string names for all flags that are set in this EquipmentBitSet.inthashCode()booleanintersects(EquipmentBitSet other) or(EquipmentFlag... flags) Returns a copy of this EquipmentBitSet with the specified flags set.voidset(EquipmentFlag flag) Sets the flag in the EquipmentBitSet.toString()
-
Constructor Details
-
EquipmentBitSet
public EquipmentBitSet()Default constructor. -
EquipmentBitSet
Copy constructor.- Parameters:
other- the EquipmentBitSet to copy
-
-
Method Details
-
get
Returns true if the flag is set in the EquipmentBitSet.- Parameters:
flag- the flag to check- Returns:
- true if the flag is set in the EquipmentBitSet
-
contains
-
intersects
-
clear
Clears the flag in the EquipmentBitSet.- Parameters:
flag- the flag to clear
-
clear
public void clear()Clears all flags in the EquipmentBitSet. -
set
Sets the flag in the EquipmentBitSet.- Parameters:
flag- the flag to set
-
or
Returns a copy of this EquipmentBitSet with the specified flags set.- Parameters:
flags- the flags to set- Returns:
- a copy of this EquipmentBitSet with the flags set
-
andNot
Returns a copy of this EquipmentBitSet with the flag cleared.- Parameters:
flag- the flag to clear- Returns:
- a copy of this EquipmentBitSet with the flag cleared
-
and
Returns a new empty EquipmentBitSet and the flags set if it is set in this EquipmentBitSet. Example: EquipmentBitSet a = new EquipmentBitSet(); a.set(F_HEAT_SINK); a.set(F_DOUBLE_HEATSINK); a.and(F_HEAT_SINK) // EquipmentBitSet with only F_HEAT_SINK set if it was originally set a.has(F_HEAT_SINK); // true a.has(F_DOUBLE_HEATSINK); // false- Parameters:
flags- the flags to check- Returns:
- a new empty EquipmentBitSet and the flag set if it is set in this EquipmentBitSet
-
getSetFlagNames
Returns a list of string names for all flags that are set in this EquipmentBitSet.- Parameters:
flagEnum- the enum class to check against (e.g., MiscTypeFlag.class, WeaponTypeFlag.class)- Returns:
- list of flag names that are set in this bitset
-
getSetFlagNamesAsArray
Returns an array of string names for all flags that are set in this EquipmentBitSet.- Parameters:
flagEnum- the enum class to check against (e.g., MiscTypeFlag.class, WeaponTypeFlag.class)- Returns:
- array of flag names that are set in this bitset
-
toString
-
equals
-
hashCode
public int hashCode()
-