Class EntityDataMap<F extends Enum<F>>

java.lang.Object
megamek.ai.dataset.EntityDataMap<F>
Type Parameters:
F - The enum type representing field names
Direct Known Subclasses:
BoardData, GameData, MapSettingsData, PlanetaryConditionsData, UnitAction, UnitAttack, UnitState

public abstract class EntityDataMap<F extends Enum<F>> extends Object
Abstract base class for data maps that use enum fields.
  • Constructor Details

    • EntityDataMap

      protected EntityDataMap(Class<F> fieldEnumClass)
      Creates an empty EntityDataMap.
      Parameters:
      fieldEnumClass - The class of the enum type F
  • Method Details

    • put

      public EntityDataMap<F> put(F field, Object value)
      Adds a field to the data map.
      Parameters:
      field - The field enum
      value - The field value
      Returns:
      This EntityDataMap for method chaining
    • get

      public Object get(F field)
      Gets a field value from the data map.
      Parameters:
      field - The field enum
      Returns:
      The field value, or null if not present
    • get

      public <T> T get(F field, Class<T> type)
      Gets a field value with type casting.
      Type Parameters:
      T - The expected type
      Parameters:
      field - The field enum
      type - The class of the expected type
      Returns:
      The field value cast to the expected type, or null if not present
    • getAllFields

      public Map<F,Object> getAllFields()
      Gets all fields and values in the map.
      Returns:
      The underlying map of data
    • getFieldOrder

      public List<F> getFieldOrder()
      Gets the ordered list of field enums.
      Returns:
      List of fields in insertion order
    • getFieldEnumClass

      public Class<F> getFieldEnumClass()
      Gets the class of the field enum.
      Returns:
      The enum class