We are thinking about doing some JQAssistant concepts/rules based on the values of annotation attributes.
Can these values be queried and evaluated with JQAssistant?
Example: Find all classes that have methods that are annotated with
@javax.ejb.TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
The following query returns all types annotated by @TransactionAttribute
and the value:
MATCH
(t:Type)-[:ANNOTATED_BY]->(txAttribute)-[:OF_TYPE]->(:Type{fqn:"javax.ejb.TransactionAttribute"}),
(txAttribute)-[:HAS]->(:Value{name:"value"})-[:IS]->(txAttributeType:Field)
RETURN
t.fqn, txAttributeType.signature
The result looks like this:
"your.project.a.impl.ServiceAImpl" "javax.ejb.TransactionAttributeType REQUIRES_NEW"
The returned value is the signature of the according field declared in the enum type TransactionAttributeType
.