A Count is defined by a method with the @Count annotation:
The name of the method has a special meaning if (and only if) the
For instance, a Count for the attribute
The value of the attribute will be updated to reflect the number of child objects whenever necessary. This includes objects being added to and removed from the parent object, as well as modifications to the children objects that change their qualification in the Count.
A Count is not recalculated from scratch, but rather adjusted as necessary. For instance, when a new (qualifiying) child is added to the parent, the Count attribute will be incremented by one. This means that there is very little performance impact.
If the method contains code, that code will be invoked every time the count is adjusted, but this is meant only as a debugging aid: the code should not do anything that affects the object.