TSerializableCustomId<T> class abstract

Abstract base class providing serialization for objects with typed identifiers.

Extends TWriteableCustomId and adds convenience methods for converting the object into YAML, Markdown, and XML representations. This class provides type-safe ID handling through the generic type parameter T.

Type parameter T represents the type of the object's identifier (typically String, but can be any non-nullable type).

Example with String ID:

class User extends TSerializableCustomId<String> {
  User({required this.name});

  final String name;

  @override
  String get id => 'user-123';

  @override
  Map<String, dynamic> toJson() => {'name': name};
}

Example with custom ID type:

class CustomId {
  const CustomId(this.value);
  final int value;
}

class Document extends TSerializableCustomId<CustomId> {
  Document() : _id = CustomId(42);

  final CustomId _id;

  @override
  CustomId get id => _id;

  @override
  Map<String, dynamic> toJson() => {'id': _id.value};
}
Inheritance

Constructors

TSerializableCustomId()

Properties

hashCode int
The hash code for this object.
no setterinherited
id → T
The unique identifier for this document.
no setterinherited
markdownBuilder String Function(Map<String, dynamic> json)?
Returns a function that builds a Markdown string from a JSON map.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
xmlBuilder String Function(Map<String, dynamic> json)?
Returns a function that builds an XML string from a JSON map.
no setter
yamlBuilder String Function(Map<String, dynamic> json)?
Returns a function that builds a YAML string from a JSON map.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the object to a Firestore-compatible map.
inherited
toMarkdown() String
Converts this object to a Markdown string.
toString() String
A string representation of this object.
inherited
toXml() String
Converts this object to an XML string.
toYaml() String
Converts this object to a YAML string.
validate<T>() → TurboResponse<T>?
Validates the object's data before writing to Firestore.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited