I am facing problem with creating some metadata structure inside annotations. We are using annotations for define special attributes for hibernate entity attributes but it might be usable everywhere. I want to create condition which represent these structure:
attribute1 = ...
OR
(attribute2 = ...
AND
attribute3 = ...)
Problem is that I need to define some "tree" structure using this annotations. Here is some design I want to reach:
@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 these annotation 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 inheritance in that way I defined in the annotation definition above is not possible. But how can I consider my annotations AND, OR to be in one "family"?