Id<T> class
abstract
Represents a generic identifier for entities within the domain model.
This abstract class extends SingleTypeValueObject to encapsulate an identifier value
of a specific type T
. It provides a standard way to handle entity identifiers across
the domain, ensuring they are treated as value objects with value-based equality.
The class overrides the equality and hash code methods to compare identifier instances
based on their encapsulated value, and provides a toString
method for convenient
string representation of the identifier.
Usage:
class UserId extends Id<String> {
UserId(String value) : super(value);
}
- Inheritance
Properties
- hashCode → int
-
Gets the hash code for the identifier.
no setteroverride
-
props
→ List<
Object?> -
A list containing the encapsulated value for equality and hash code calculations.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
Public getter to expose the encapsulated value of the value object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation of the identifier.
override
Operators
-
operator ==(
Object other) → bool -
Compares this identifier to another object.
override