# NegationNode

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/ast/NegationNode.java+class:androidx.appsearch.ast.NegationNode) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
@ExperimentalAppSearchApi
class NegationNode : Node
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/appsearch/ast/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 `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/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](https://google.aip.dev/assets/misc/ebnf-filtering.txt).

This API may change in response to feedback and additional changes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#NegationNode(androidx.appsearch.ast.Node)(childNode: https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node)` Constructor for a `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` that takes in a child node of any `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` type. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#getChild()()` Retrieve the child node of this Node. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#getChildren()()` Retrieve the child node of this Node as a list containing the only child node. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#setChild(androidx.appsearch.ast.Node)(child: https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node)` Set the child node that the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` holds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode#toString()()` Get the string representation of `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode`. |

## Public constructors

### NegationNode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
NegationNode(childNode: Node)
```

Constructor for a `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` that takes in a child node of any `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/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 `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` will make that `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` a child of another `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode`, NOT a new `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` with the same child as the original `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode`.

| Parameters |
|---|---|
| `childNode: https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` | The `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` representing some query to be logically negated. |

## Public functions

### equals

```
fun equals(o: Any!): Boolean
```

### getChild

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getChild(): Node
```

Retrieve the child node of this Node.

This method will return the child node as a `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` but could be of any type that implements `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node`. The caller should check what type the child node is and cast it to that type accordingly.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` | The child `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` representing a query that is being logically negated that could be cast to a type that implements `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` |

### getChildren

```
fun getChildren(): (Mutable)List<Node!>
```

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 `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` but could be of any type that implements `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node`. The caller should check what type the child node is and cast it to that type accordingly.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node!>` | A list of size one containing a child `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` representing a query that is being logically negated that could be cast to a type that implements `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` |

### hashCode

```
fun hashCode(): Int
```

### setChild

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun setChild(child: Node): Unit
```

Set the child node that the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` holds.

The node will be treated such that search will return everything not matching the term contained in the child.

| Parameters |
|---|---|
| `child: https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` | The child node that `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` will hold. |

### toString

```
fun toString(): String
```

Get the string representation of `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode`.

The string representation of `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/NegationNode` is "NOT" prepended to the string representation of the child `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node`.