2

I would like to implement some naming conventions with the help of jQAssistant. All classes implementing the PropertyConverter interface should have names ending with Converter. This rule does not apply to anonymous inner classes. Now I have two queries. This one returns all classes violating the naming rule:

MATCH   (t:Type)-[:IMPLEMENTS]->(i:Type) 
WHERE   i.fqn='PropertyConverter' And
NOT     t.name =~ '.*Converter'
RETURN  t.fqn

But this query also returns inner classes which have names like ABC$1. I can find these classes with the following query:

 MATCH  (t:Type)-[:IMPLEMENTS]->(i:Type)
 WHERE  i.fqn='org.apache.tamaya.PropertyConverter'
        AND NOT t.name =~ '.*Converter'
 WITH   t
 MATCH  (h:Type)-[:DECLARES]->(t)
 RETURN distinct t.fqn, h.fqn

But I was unable to combine both queries so that I will get only the results of the first query which are not contained in the second result set.

How can I combine both queries?

Oliver
  • 3,815
  • 8
  • 35
  • 63

1 Answers1

3

The best approach would be using the pre-defined concept to identify anonymous inner types ("java:AnonymousInnerType"). It comes with the Java plugin and would make your constraint look like this:

<constraint id="...">
  <requiresConcept refId="java:AnonymousInnerType" />
  <description>All classes implementing the PropertyConverter interface must have the suffix "Converter".</description>
  <cypher>
    MATCH 
      (t:Type)-[:IMPLEMENTS]->(i:Type)
    WHERE
      i.fqn='PropertyConverter'
      and not t:Anonymous:Inner
      and not t.name =~ '.*Converter'
    RETURN
      t.fqn
  </cypher>
</constraint>
Oliver
  • 3,815
  • 8
  • 35
  • 63
Dirk Mahler
  • 1,186
  • 1
  • 6
  • 7