com.dragome.forms.bindings.client.bean.LimitPropertyDepth Maven / Gradle / Ivy
Show all versions of dragome-form-bindings Show documentation
package com.dragome.forms.bindings.client.bean;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation can be added to {@link BeanModelProvider} declarations
* to let tell the rebind process know how deep to traverse recursive
* property paths. A recursive property is one that returns another property
* the same type as itself either as a directed descendant or as a descendant
* of another property (at any depth).
*
* As example you may have an employee that has a manager who is also an employee
* and so on up the chain. e.g. employee.getManager().getManager()
etc.
* Since such a path is infinitely recursive Pectin needs to be given a limit for the depth
* that the code generation will generate (since valid property paths are computed at compile time).
*
* The follow example will limit the maximum depth of any property paths to 3. So this would limit
* the manager example above to provider.getValueModel("manager.manager.manager", Employee.class)
*
* @NestedTypes({Employee.class})
* @LimitPropertyDepth(3)
* public static class EmployeeProvider extends BeanModelProvider<Employee>{}
*
*
* NOTE: This annotation is only required if the provider has nested types and the bean has recursive paths. Pectin will
* throw an exception during the rebind process if this annotation is required but has not been specified. (I.e. if you're not getting
* the exception then you don't need the annotation).
*
* NOTE: You don't need to be exact with depth as the optimisation process will strip any unused paths.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface LimitPropertyDepth
{
int value();
}