Entities Overview

What is an Entity ?

An Entity is a modddel that holds other modddels (ValueObjects or Entities).

An Entity always has a special validation which we call the "contentValidation". During the contentValidation, the modddels that are held inside the entity are verified. If they are all valid, the contentValidation passes successfully. If one of them is invalid, the contentValidation fails with a ContentFailure, which holds the invalid modddel(s) and their failure(s).

In addition to the contentValidation, entities can have additionnal validations that you specify. Each validation either passes successfully, or fails with an EntityFailure.

The ContentFailure is a subclass of EntityFailure, which is a subclass of Failure.

Entities Kinds

There are three kinds of entities :

  • SimpleEntity : Holds the modddels as separate fields. Ex: A Person SimpleEntity that has two fields : Age age and FullName name.

  • IterableEntity : Holds a collection of modddels of the same type. The collection must be able to be converted to an iterable of modddels. Ex: List<M>, Set<M>, Map<int,M>... where M is the type of the modddel.

  • Iterable2Entity : Holds a collection of modddels of two types. The collection must be able to be converted to two iterables of modddels. Ex: Map<M1, M2>, Map<M1, List<M2>>... where M1 and M2 are the two modddels types.