I want to ensure that all enums have a static method called findByAttribute
.
I can select the method by
MATCH (enum:Enum) - [:DECLARES] -> (method:Method)
WHERE method.static = true
AND method.name = "findByAttribute"
RETURN enum.name, method.name
Now I want to inverse the condition of method selection. I tried NOT EXITS
but that didn't work.
First, here are all the operators you can use, and how to use them
The easiest way is to use bubbles to group your logic. (This is probably the easiest to understand with one read through)
MATCH (enum:Enum) - [:DECLARES] -> (method:Method)
WHERE NOT (method.static = true
AND method.name = "findByAttribute")
RETURN enum.name, method.name
The next best thing is NOT (A and B)
=NOT A OR NOT B
MATCH (enum:Enum) - [:DECLARES] -> (method:Method)
WHERE NOT method.static = true
OR NOT method.name = "findByAttribute"
RETURN enum.name, method.name
or using the inequality operator <>
instead of inverting the Boolean
MATCH (enum:Enum) - [:DECLARES] -> (method:Method)
WHERE method.static <> true
OR method.name <> "findByAttribute"
RETURN enum.name, method.name
EXISTS is to merely check if a property is set, so doesn't really apply here because it can be set.
Assuming by inverse you meant "WHERE this method doesn't exist", you can NOT a pattern match (cut out method.name from return since there is no logical way to include it in this version of query)
MATCH (enum:Enum)
WHERE NOT (enum) - [:DECLARES] -> (:Method {static:true, name:"findByAttribute"})
RETURN enum.name