我想在 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/