CollectionEntry

ceramic.CollectionEntry (Class) → ValueEntry

Base class for entries that can be stored in a Collection.

CollectionEntry provides:

  • Automatic unique ID generation
  • Runtime index for fast integer-based identification
  • Flexible data deserialization from raw data (CSV, JSON, etc.)
  • Type conversion for common data types

When creating custom collection entries, extend this class and add your specific fields. The FieldInfoMacro will automatically generate type information for proper deserialization.

Example usage:

class EnemyEntry extends CollectionEntry {
    public var health:Int = 100;
    public var damage:Float = 10.5;
    public var isFlying:Bool = false;
    public var enemyType:EnemyType; // Enum support
}

// Create from raw data (e.g., from CSV)
var enemy = new EnemyEntry();
enemy.setRawData({
    id: "goblin1",
    health: "50",
    damage: "5.5",
    isFlying: "true",
    enemyType: "GOBLIN"
});

Instance Members

Unique identifier for this entry. Auto-generated if not provided in constructor.


name: String

Optional human-readable name for this entry.


index: Int

A unique runtime index for this collection entry instance.

Warning: This index is not persistent and will vary between app runs! Use it only for fast runtime lookups, never for saving/loading data. For persistent identification, use the 'id' field instead.


setRawData(data: Dynamic): Void

Sets entry fields from raw data, with automatic type conversion.

Supports conversion from strings (e.g., CSV data) to:

  • Bool: "true"/"false", "yes"/"no", "1"/"0"
  • Int: Numeric strings
  • Float: Numeric strings (accepts comma as decimal separator)
  • Color: Integer color values
  • String: Any value (null becomes null)
  • Enum: Case-insensitive enum constructor names

Fields marked with @skipEmpty meta will be skipped if the raw value is null or empty.

Name Type Description
data Dynamic Object containing field names and raw values

setRawField(name: String, rawValue: Dynamic): Bool

Override this method to handle custom field deserialization.

Return true to skip default type conversion for the field. Useful for complex types or custom parsing logic.

Name Type Description
name String The field name
rawValue Dynamic The raw value to process
Returns Description
Bool True if field was handled, false to use default conversion

new(?id: String, ?name: String): Void

Creates a new CollectionEntry.

Name Type Default Description
id String (optional) Optional unique identifier (auto-generated if not provided)
name String (optional) Optional human-readable name

Private Members

Metadata

Name Parameters
:structInit -
:keepSub -