# AndNode

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

*** ** * ** ***


```
@ExperimentalAppSearchApi
public final class AndNode implements Node
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/appsearch/ast/Node` that represents logical AND of nodes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#AndNode(java.util.List<androidx.appsearch.ast.Node>)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/appsearch/ast/Node> childNodes)` Constructor for `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode` that represents logical AND over all its child nodes. |
| `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#AndNode(androidx.appsearch.ast.Node,androidx.appsearch.ast.Node,androidx.appsearch.ast.Node...)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node firstChild, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node secondChild, @https://developer.android.com/reference/androidx/annotation/NonNull Node[] additionalChildren )` Convenience constructor for `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode` that represents logical AND over all its child nodes and takes in a varargs of nodes. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#addChild(androidx.appsearch.ast.Node)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node childNode)` Add a child node to the end of the current list of child nodes `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#mChildren()`. |
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html o)` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/appsearch/ast/Node>` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#getChildren()()` Get the list of nodes being logically ANDed over by this node. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#getIndexOfChild(androidx.appsearch.ast.Node)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node node)` Returns the index of the first instance of the node, or -1 if the node does not exist. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#removeChild(androidx.appsearch.ast.Node)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node node)` Removes the given `https://developer.android.com/reference/androidx/appsearch/ast/Node` from the list of child nodes. |
| `void` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#setChild(int,androidx.appsearch.ast.Node)(int index, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node childNode)` Replace the child node at the provided index with the provided `https://developer.android.com/reference/androidx/appsearch/ast/Node`. |
| `void` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#setChildren(java.util.List<androidx.appsearch.ast.Node>)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/appsearch/ast/Node> childNodes)` Set the nodes being logically ANDed over by this node. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#toString()()` Gets the string representation of `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode`. |

## Public constructors

### AndNode

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

```
public AndNode(@NonNull List<Node> childNodes)
```

Constructor for `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode` that represents logical AND over all its child nodes.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/appsearch/ast/Node> childNodes` | The list of `https://developer.android.com/reference/androidx/appsearch/ast/Node` of at least size two representing queries to be logically ANDed over. |

### AndNode

```
public AndNode(
    @NonNull Node firstChild,
    @NonNull Node secondChild,
    @NonNull Node[] additionalChildren
)
```

Convenience constructor for `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode` that represents logical AND over all its child nodes and takes in a varargs of nodes.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node firstChild` | The first node to be ANDed over, which is required. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node secondChild` | The second node to be ANDed over, which is required. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Node[] additionalChildren` | Additional nodes to be ANDed over, which are optional. |

## Public methods

### addChild

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

```
public void addChild(@NonNull Node childNode)
```

Add a child node to the end of the current list of child nodes `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#mChildren()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node childNode` | A `https://developer.android.com/reference/androidx/appsearch/ast/Node` to add to the end of the list of child nodes. |

### equals

```
public boolean equals(Object o)
```

### getChildren

```
public @NonNull List<Node> getChildren()
```

Get the list of nodes being logically ANDed over by this node.

### getIndexOfChild

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

```
public int getIndexOfChild(@NonNull Node node)
```

Returns the index of the first instance of the node, or -1 if the node does not exist.

### hashCode

```
public int hashCode()
```

### removeChild

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

```
public boolean removeChild(@NonNull Node node)
```

Removes the given `https://developer.android.com/reference/androidx/appsearch/ast/Node` from the list of child nodes. If multiple copies of the node exist, then the first `https://developer.android.com/reference/androidx/appsearch/ast/Node` that matches the provided `https://developer.android.com/reference/androidx/appsearch/ast/Node` will be removed. If the node does not exist, the list will be unchanged.

The list of child nodes must contain at least 3 nodes to perform this operation.

| Returns |
|---|---|
| `boolean` | `true` if the node was removed, `false` if the node was not removed i.e. the node was not found. |

### setChild

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

```
public void setChild(int index, @NonNull Node childNode)
```

Replace the child node at the provided index with the provided `https://developer.android.com/reference/androidx/appsearch/ast/Node`.

| Parameters |
|---|---|
| `int index` | The index at which to replace the child node in the list of child nodes. Must be in range of the size of `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode#mChildren()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/ast/Node childNode` | The `https://developer.android.com/reference/androidx/appsearch/ast/Node` that is replacing the childNode at the provided index. |

### setChildren

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

```
public void setChildren(@NonNull List<Node> childNodes)
```

Set the nodes being logically ANDed over by this node.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/appsearch/ast/Node> childNodes` | A list of `https://developer.android.com/reference/androidx/appsearch/ast/Node` of at least size two representing the nodes to be logically ANDed over in this node. |

### toString

```
public @NonNull String toString()
```

Gets the string representation of `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode`.

The string representation of `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode` is the string representation of `https://developer.android.com/reference/androidx/appsearch/ast/operators/AndNode`'s child nodes joined with "AND", all surrounded by parentheses.