AggregateRoot class abstract

Inheritance

Constructors

AggregateRoot()

Properties

code String
An optional human-readable string code identifying the entity. If null, defaults to 'code'. If concept says updateCode is false, cannot update.
getter/setter pairinherited
codeFirstLetterLower String
Utility property returning the code's first letter in lowercase.
no setterinherited
codeFirstLetterUpper String
Utility property returning the code's first letter in uppercase.
no setterinherited
codeLowerSpace String
Utility property returning the code in lower space-separated form.
no setterinherited
codeLowerUnderscore String
Utility property returning the code in lower_snake_case form.
no setterinherited
codePlural String
Utility property returning the code in plural form.
no setterinherited
codePluralFirstLetterLower String
Utility property returning the plural code, first letter lowercased.
no setterinherited
codePluralFirstLetterUpper String
Utility property returning the plural code, first letter uppercased.
no setterinherited
codePluralFirstLetterUpperSpace String
Utility property returning the plural code in a spaced form with uppercase first letter.
no setterinherited
codePluralLowerUnderscore String
Utility property returning the plural code in lower_snake_case.
no setterinherited
concept Concept
The Concept describing the domain structure for this entity. If _concept is null, throws EDNetException.
getter/setter pairinherited
exceptions IValidationExceptions
Accumulates validation or policy violation exceptions. Each time entity updates happen, exceptions may record domain errors.
getter/setter pairinherited
hashCode int
Hashes the entity by its oid.
no setterinherited
id Id?
The Id aggregates all identifier attributes or parent references. If the concept has none, returns null.
no setterinherited
oid Oid
Unique object identifier (OID) for the entity. By default, this is assigned on creation, but can be changed if concept.updateOid is true.
getter/setter pairinherited
policyEvaluator PolicyEvaluator
Allows external configuration of the PolicyEvaluator.
no getterinherited
post bool
getter/setter pairinherited
pre bool
Hooks to control pre/post conditions on attribute/relationship changes. pre indicates if we do pre-validation logic, post for post-validation.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
whenAdded DateTime?
Timestamp of when the entity was first created or added. Only updatable if concept.updateWhen is true.
getter/setter pairinherited
whenRemoved DateTime?
Timestamp of when the entity was logically removed. Only updatable if concept.updateWhen is true.
getter/setter pairinherited
whenSet DateTime?
Timestamp of the latest attribute or relationship update. Used for partial concurrency or auditing.
getter/setter pairinherited

Methods

compareAttributes(AggregateRoot entity) int
Compare attributes one by one until a difference is found. Return negative if this < that; zero if same; positive if this > that.
inherited
compareTo(dynamic entity) int
Compare two entities, primarily using code, otherwise id, otherwise attribute comparisons. If negative, this < that; zero => equal; positive => this > that.
inherited
copy() AggregateRoot
Creates a shallow copy of this entity. OID, code, attributes, and references are duplicated. Child/parent references are not deeply cloned but re-linked.
inherited
display({String prefix = '', bool withOid = true, bool withChildren = true, bool withInternalChildren = true}) → void
Displays this entity’s details, including attributes, parents, children.
inherited
displayToString() → void
Prints toString().
inherited
equalContent(AggregateRoot entity) bool
Checks if the content (attributes, code, parents, children) matches another entity. Ignores oid, whenAdded, whenSet, whenRemoved.
inherited
equals(AggregateRoot entity) bool
Equality is based on oid. If their OIDs match, they are considered the same entity.
inherited
evaluatePolicies({String? policyKey}) PolicyEvaluationResult
Evaluates entity-level and model-level policies for this entity. If a policyKey is provided, only that specific policy is evaluated.
inherited
fromJson<K extends Entity<K>>(String entityJson) → void
Populates this entity's data from a JSON string. Deserializes via fromJsonMap.
inherited
fromJsonMap(dynamic entityMap, [Entity<Entity>? internalParent]) → void
Internal: loads entity data from a map entityMap, optionally linking to an internalParent.
inherited
getAttribute<K>(String attributeCode) → K?
Retrieves the attribute value for attributeCode as type K. Returns null if not set.
inherited
getChild(String? name) Object?
Retrieves the child collection matching name. Or null if no such child is defined.
inherited
getInternalChild(String name) Object?
Gets the internal child collection reference by name.
inherited
getParent(String name) Object?
Gets the parent entity by name, or null if none.
inherited
getReference(String name) Reference?
Returns the Reference to a parent by name, if any.
inherited
getRelationship(String relationshipName) → dynamic
Retrieves either a parent or child relationship by name. Returns null if neither is found.
inherited
getStringFromAttribute(String name) String?
Returns the attribute value as a string. If the value is null, returns 'null'.
inherited
getStringOrNullFromAttribute(String name) String?
Returns the attribute value as a nullable string, or null if no value.
inherited
newEntities() Entities<AggregateRoot>
Creates a new Entities<E> collection that can hold instances of this entity. The new collection references the same Concept.
inherited
newEntity() Entity<AggregateRoot>
Creates a new empty instance of this entity type. The returned entity has the same Concept as the original.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
postSetAttribute(String name, Object? value) bool
Called after setting an attribute. If post is true, can run additional checks. Return false if you want to revert the update.
inherited
preSetAttribute(String name, Object? value) bool
Called before setting an attribute. If pre is true, can run additional checks. If returns false, attribute set operation is not performed.
inherited
removeParent(String name) → dynamic
Removes a parent reference by name, if parent.update is true. Reverts if policies are violated.
inherited
setAttribute(String name, Object? value) bool
Sets an attribute by name to value, respecting update rules and calling policy checks. Returns true if the attribute was successfully updated. Throws UpdateException if the attribute is not updatable or absent. Also handles policy checks, reverting changes if policies fail.
inherited
setAttributesFrom(Entity<Entity> entity) bool
Bulk-updates this entity’s attributes from another entity if whenSet is older. Only non-identifier attributes are considered. Returns true if all updated.
inherited
setChild(String name, Object entities) bool
Updates a child relationship name with entities. If child.update is false, we throw an UpdateException. If policies fail, we revert.
inherited
setParent(String name, dynamic entity) bool
Sets or updates a parent relationship named name with the given entity. If parent is uninitialized or updatable, we store a reference. If policies fail, we revert.
inherited
setReference(String name, Reference reference) → void
Sets a Reference for a parent name, but only if that parent slot is empty.
inherited
setStringToAttribute(String name, String string) bool
Helper to parse a string and update the attribute name accordingly. If the attribute type is recognized (e.g., int, bool), we parse the string. Otherwise, store the string as-is.
inherited
toGraph() Map<String, dynamic>
Converts this entity to a graph-like structure, including references to parents.
inherited
toJson() String
Serializes this entity to JSON using toJsonMap.
inherited
toJsonMap() Map<String, Object>
Builds a JSON-like Map of this entity's data, including parent references.
inherited
toString() String
Returns a concise string representation using the entity's oid and code.
inherited

Operators

operator ==(Object other) bool
The == operator delegates to equals. If other is not an Entity, returns false.
inherited