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

Constructor for a NegationNode that takes in a child node of any Node type.

Public methods

@NonNull Node

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.

void

Set the child node that the NegationNode holds.

Public constructors

NegationNode

Added in 1.1.0-alpha06
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.

Parameters
@NonNull Node childNode

The Node representing some query to be logically negated.

Public methods

getChild

Added in 1.1.0-alpha06
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.

Returns
@NonNull Node

The child Node representing a query that is being logically negated that could be cast to a type that implements Node

getChildren

public @NonNull List<NodegetChildren()

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.

Returns
@NonNull List<Node>

A list of size one containing a child Node representing a query that is being logically negated that could be cast to a type that implements Node

setChild

Added in 1.1.0-alpha06
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 NegationNode will hold.