I am trying to create some information tree structure inside annotations. After some tryings and helps (see Type hierarchy in java annotations) I moved to following model.
@interface Node {
LogicalExpression logicalExpression() default LogicalExpression.AND;
Attribute[] attributes() default {};
Node[] nodes() default {};
}
This node should allow me define one level of condition tree. Value inside logicalExpression defines relation between children (attributes and another nodes). Problem is that annotation does not allow recursive dependency:
Cycle detected: the annotation type Node cannot contain attributes of the annotation type itself
Even if I put some NodeList annotation into Node and NodeList contain list of Nodes the cyclic dependency is recognized again.
@interface NodeList {
Node[] nodes();
}
@interface Node {
LogicalExpression logicalExpression() default LogicalExpression.AND;
Attribute[] attributes() default {};
NodeList nodes() default EmptyList;
}
Is there any solution on cyclic annotation definition?