I ran into the problem of creating some kind of metadata structure inside annotations. We use annotations to define special attributes for hibernation entity attributes, but they can be used everywhere. I want to create a condition that represents this structure:
attribute1 = ... OR (attribute2 = ... AND attribute3 = ...)
The problem is that I need to define some βtree-likeβ structure using these annotations. Here is the design I want to achieve:
@interface Attribute { ... some attributes ... } @interface LogicalExpression { } @interface OR extends LogicalExpression { Attribute[] attributes() default {}; LogicalExpression logicalExpressions() default {}; } @interface AND extends LogicalExpression { Attribute[] attributes() default {}; LogicalExpression logicalExpressions() default {}; } @interface ComposedCondition { Attribute[] attributes() default {}; LogicalExpression logicalExpressions() default {}; }
All of these annotations that I want to use according to this example:
public class Table { @ComposedCondition(logicalExressions = { @OR(attributes = {@Attribute(... some settings ...)}, logicalExpressions = { @AND(attributes = {@Attribute(...), @Attribute(...)}) }) } private String value; }
I know that inheriting in the way that I defined in the definition of annotation above is not possible. But how can I view my annotations AND, OR be in the same "family"?
source share