Package io.milton.annotations
Annotation Type ChildrenOf
-
@Target(METHOD) @Retention(RUNTIME) public @interface ChildrenOf
Marks a method as one which locates children for the given parent. The parent will always be the first method argumentThere 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@ChildOfmethod is present. It will also scan by default if any@ChildOfmethods have returned null. This can be a performance problem in many cases. To prevent@ChildrenOfmethods being used to locate single items set the allowChildLookups property to false
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanallowChildLookupsIf true (default) then the method this annotates can be used to locate single items.booleanoverrideIf 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.
-
-
-
-
override
boolean override
If 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
-
-