1

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)
jens
  • 1,763
  • 1
  • 15
  • 25

1 Answers1

3

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.

Dirk Mahler
  • 1,186
  • 1
  • 6
  • 7
  • Theres also a tutorial about annotations and values available on the project's website, see https://101.jqassistant.org/annotations-single/ – Dirk Mahler Jul 13 '18 at 18:14