java - 在 jQAssistant 查询中排除内部类

标签 java neo4j cypher jqassistant

我想在 jQAssistant 的帮助下实现一些命名约定。所有实现 PropertyConverter 接口(interface)的类都应具有以 Converter 结尾的名称。此规则不适用于匿名内部类。现在我有两个疑问。这个返回所有违反命名规则的类:

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

但是此查询还返回名称类似于 ABC$1 的内部类。我可以通过以下查询找到这些类:

 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

但是我无法合并两个查询,因此我只能获得第一个查询的结果,而第二个结果集中不包含该结果。

如何组合两个查询?

最佳答案

最好的方法是使用预定义的概念来识别匿名内部类型(“java:AnonymousInnerType”)。它带有 Java 插件,将使您的约束看起来像这样:

<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>

关于java - 在 jQAssistant 查询中排除内部类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29586837/

相关文章:

java - for 循环与数组集进行比较

java - firestoreoptions.getService 上的 Firestore 空指针异常

java - Spring @autowired

java - Spring Neo4j 事务回滚不起作用

scala - 使用 Scala 的 Play 2.x 应用程序中的 Spring Data Neo4j

php - 使用循环优化 Cypher 查询以构建时间树

neo4j - 返回Cypher中具有相同属性B的节点的属性A之和

java - Dialogflow v2 Java 客户端库使用 Spring Boot 检测 Intent : No DesignTimeAgent found for project

python - Neo4j Python py2neo授权错误

Neo4j:在 Web 界面中提供密码参数