Class EntityDataSerializer<F extends Enum<F>,T extends EntityDataMap<F>>

java.lang.Object
megamek.ai.dataset.EntityDataSerializer<F,T>
Type Parameters:
F - The enum type representing field names
T - The type of EntityDataMap to be serialized
Direct Known Subclasses:
BoardDataSerializer, GameDataSerializer, MapSettingsDataSerializer, PlanetaryConditionsDataSerializer, UnitActionSerializer, UnitAttackSerializer, UnitEnrichmentSerializer, UnitStateSerializer

public abstract class EntityDataSerializer<F extends Enum<F>,T extends EntityDataMap<F>> extends Object
Abstract base class for serializers that convert entity data maps to TSV format.
  • Field Details

  • Constructor Details

    • EntityDataSerializer

      protected EntityDataSerializer(Class<F> fieldEnumClass)
      Creates a serializer with all fields of the enum in their natural order.
      Parameters:
      fieldEnumClass - The class of the enum type F
  • Method Details

    • serialize

      public String serialize(T entityData)
    • getHeaderLine

      public String getHeaderLine()
    • addFormatHandler

      public void addFormatHandler(Class<?> type, Function<Object,String> formatter)
      Adds a custom field format handler.
      Parameters:
      type - The class type to handle
      formatter - The formatting function
    • getNullValue

      protected String getNullValue(F field)
      Gets the string representation for a null value for the given field. Subclasses can override this to provide field-specific default values.
      Parameters:
      field - The field enum
      Returns:
      The string representation for a null value