AggregateRoot<TId extends Id> class abstract

Represents the root of an aggregate, a cluster of domain entities and value objects.

This abstract class extends Entity, inheriting its identity characteristics, and serves as the foundation for all aggregate roots in the domain model. Aggregate roots are the main entry points for accessing and performing operations on aggregates, ensuring consistency and enforcing aggregate boundaries.

The generic type parameter TId represents the type of the identifier used by the aggregate root, which must extend from Id. This allows for flexibility in defining custom identifier types for different aggregates.

Usage:

class User extends AggregateRoot<UserId> {
  final String name;

  User({required UserId id, required this.name}) : super(id: id);
}
Inheritance

Constructors

AggregateRoot({required TId id})
Constructs a new instance of AggregateRoot with the provided identifier.
const

Properties

hashCode int
Gets the hash code for the entity.
no setterinherited
id → TId
Public getter to expose the entity's unique identifier.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
Compares this entity to another object.
inherited