I tried to create a "map" using nested JAVA annotations.
public @interface EnvInstance {
Env env();
Instance instance();
}
public @interface Configuration {
String description();
EnvInstance[] envInstances() default {};
}
@Configuration(description = "Test", envInstances = {
@EnvInstance(env = Env.CERT, instance = Instance.FIRST),
@EnvInstance(env = Env.INTEGR, instance = Instance.SECOND),
@EnvInstance(env = Env.PROD, instance = Instance.FIRST),
...
}
)
public class TestObject {
}
It seems to work but there is one thing I don't know how to achieve. I want to create two default sets of envInstances
configuration so I can type:
@Configuration(description = "Test", envInstances = SET_ONE)
public class TestObject {
}
or
@Configuration(description = "Test", envInstances = SET_TWO)
public class TestObject {
}
Is there a possibility to create a static array of inner annotations or something like this and pass it to the outer annotation?