Package megamek.ai.dataset
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 namesT- 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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final DecimalFormatstatic final Stringstatic final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEntityDataSerializer(Class<F> fieldEnumClass) Creates a serializer with all fields of the enum in their natural order. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFormatHandler(Class<?> type, Function<Object, String> formatter) Adds a custom field format handler.protected StringgetNullValue(F field) Gets the string representation for a null value for the given field.
-
Field Details
-
LOG_DECIMAL
-
formatHandlers
-
TAB
- See Also:
-
VERSION
- See Also:
-
-
Constructor Details
-
EntityDataSerializer
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
-
getHeaderLine
-
addFormatHandler
Adds a custom field format handler.- Parameters:
type- The class type to handleformatter- The formatting function
-
getNullValue
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
-