Package io.milton.annotations
Annotation Interface ChildrenOf
Marks a method as one which locates children for the given parent. The parent
will always be the first method argument
There may be multiple matching childrenOf methods for a given parent object, in which case all of the results are merged into a single set
The method must:
- return a collection, or array, or a single POJO object which has appropriate controllers
- the first argument must be the hierarchical parent of these objects
Example:
@ChildrenOf
public List<Band> getBands(BandsController root) {
return Band.findAll(SessionManager.session());
}
Performance Tip
Note that Milton will scan children collections to locate single objects
as part of resource location if no @ChildOf method is present. It will
also scan by default if any @ChildOf methods have returned null. This
can be a performance problem in many cases. To prevent @ChildrenOf methods
being used to locate single items set the allowChildLookups property to false-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanIf true (default) then the method this annotates can be used to locate single items.booleanIf true this method will replace (ie override) calls to any other methods with a target base class For example if you have @ChildrenOf method targeting Animal, and another method targeting Cat, then by default both sets of resources will be combined to produce children for a source object of Cat.
-
Element Details
-
allowChildLookups
boolean allowChildLookupsIf true (default) then the method this annotates can be used to locate single items. Otherwise this method will be ignored for single child lookups- Returns:
- Default:
- true
-
override
boolean overrideIf true this method will replace (ie override) calls to any other methods with a target base class For example if you have @ChildrenOf method targeting Animal, and another method targeting Cat, then by default both sets of resources will be combined to produce children for a source object of Cat. But by setting override to true only the Cat method will be used- Returns:
- Default:
- false
-