Class EquipmentBitSet

java.lang.Object
megamek.common.equipment.EquipmentBitSet

public class EquipmentBitSet extends Object
Represents a set of flags that can be used to represent the type and special properties of the equipment.
  • Constructor Details

    • EquipmentBitSet

      public EquipmentBitSet()
      Default constructor.
    • EquipmentBitSet

      public EquipmentBitSet(EquipmentBitSet other)
      Copy constructor.
      Parameters:
      other - the EquipmentBitSet to copy
  • Method Details

    • get

      public boolean get(EquipmentFlag flag)
      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

      public boolean contains(EquipmentBitSet other)
    • intersects

      public boolean intersects(EquipmentBitSet other)
    • clear

      public void clear(EquipmentFlag flag)
      Clears the flag in the EquipmentBitSet.
      Parameters:
      flag - the flag to clear
    • clear

      public void clear()
      Clears all flags in the EquipmentBitSet.
    • set

      public void set(EquipmentFlag flag)
      Sets the flag in the EquipmentBitSet.
      Parameters:
      flag - the flag to set
    • or

      public EquipmentBitSet or(EquipmentFlag... flags)
      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

      public EquipmentBitSet andNot(EquipmentFlag flag)
      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

      public EquipmentBitSet and(EquipmentFlag... flags)
      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

      public <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.
      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

      public <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.
      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

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object