NegationNode
@ExperimentalAppSearchApi
public final class NegationNode implements Node
Node that stores a child node to be logically negated with a negative sign ("-") or 'NOT'.
The child node stored in this node will be negated in a query search, which means search will return all documents that do not match the sub-expression represented by the child node. For example, if the child node is a TextNode containing "foo", the resulting node will be treated as the query `-foo` or alternatively `NOT foo`.
This node should correspond to `(NOT WS | MINUS) simple` in Google AIP EBNF Filtering Definition.
This API may change in response to feedback and additional changes.
Summary
Public constructors |
|---|
NegationNode(@NonNull Node childNode)Constructor for a |
Public methods |
|
|---|---|
boolean |
|
@NonNull Node |
getChild()Retrieve the child node of this Node. |
@NonNull List<Node> |
Retrieve the child node of this Node as a list containing the only child node. |
int |
hashCode() |
void |
Set the child node that the |
@NonNull String |
toString()Get the string representation of |
Public constructors
NegationNode
public NegationNode(@NonNull Node childNode)
Constructor for a NegationNode that takes in a child node of any Node type.
The resulting NegationNode represents the logical negation of its child node. For example if the child node represents `foo AND bar` then the resulting NegationNode represents `-(foo AND bar)` or alternatively `NOT (foo AND bar)`
This constructor is NOT a copy constructor. Passing in a NegationNode will make that NegationNode a child of another NegationNode, NOT a new NegationNode with the same child as the original NegationNode.
Public methods
getChild
public @NonNull Node getChild()
Retrieve the child node of this Node.
This method will return the child node as a Node but could be of any type that implements Node. The caller should check what type the child node is and cast it to that type accordingly.
getChildren
public @NonNull List<Node> getChildren()
Retrieve the child node of this Node as a list containing the only child node.
This method will return the child node as a List of size one containing a Node but could be of any type that implements Node. The caller should check what type the child node is and cast it to that type accordingly.
setChild
public void setChild(@NonNull Node child)
Set the child node that the NegationNode holds.
The node will be treated such that search will return everything not matching the term contained in the child.
| Parameters | |
|---|---|
@NonNull Node child |
The child node that |
toString
public @NonNull String toString()
Get the string representation of NegationNode.
The string representation of NegationNode is "NOT" prepended to the string representation of the child Node.