@ExperimentalAppSearchApi
public final class OrNode implements Node


Node that represents logical OR of nodes.

Summary

Public constructors

OrNode(@NonNull List<Node> childNodes)

Constructor for OrNode that represents logical OR over all its child nodes.

OrNode(
    @NonNull Node firstChild,
    @NonNull Node secondChild,
    @NonNull Node[] additionalChildren
)

Convenience constructor for OrNode that represents logical OR over all its child nodes and takes in a varargs of nodes.

Public methods

void
addChild(@NonNull Node childNode)

Add a child node to the end of the current list of child nodes mChildren.

boolean
@NonNull List<Node>

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

int

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

int
boolean

Removes the given Node from the list of child nodes.

void
setChild(int index, @NonNull Node childNode)

Replace the child node at the provided index with the provided Node.

void
setChildren(@NonNull List<Node> childNodes)

Set the nodes being logically ORed over by this node.

@NonNull String

Gets the string representation of OrNode.

Public constructors

OrNode

Added in 1.1.0-alpha07
public OrNode(@NonNull List<Node> childNodes)

Constructor for OrNode that represents logical OR over all its child nodes.

Parameters
@NonNull List<Node> childNodes

The nodes representing queries to be logically ORed over.

OrNode

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

Convenience constructor for OrNode that represents logical OR over all its child nodes and takes in a varargs of nodes.

Parameters
@NonNull Node firstChild

The first node to be ORed over, which is required.

@NonNull Node secondChild

The second node to be ORed over, which is required.

@NonNull Node[] additionalChildren

Additional nodes to be ORed over, which are optional.

Public methods

addChild

Added in 1.1.0-alpha07
public void addChild(@NonNull Node childNode)

Add a child node to the end of the current list of child nodes mChildren.

Parameters
@NonNull Node childNode

A Node to add to the end of the list of child nodes.

equals

public boolean equals(Object o)

getChildren

public @NonNull List<NodegetChildren()

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

getIndexOfChild

Added in 1.1.0-alpha07
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-alpha07
public boolean removeChild(@NonNull Node node)

Removes the given Node from the list of child nodes. If multiple copies of the node exist, then the first Node that matches the provided 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-alpha07
public void setChild(int index, @NonNull Node childNode)

Replace the child node at the provided index with the provided 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 mChildren.

@NonNull Node childNode

The Node that is replacing the childNode at the provided index.

setChildren

Added in 1.1.0-alpha07
public void setChildren(@NonNull List<Node> childNodes)

Set the nodes being logically ORed over by this node.

Parameters
@NonNull List<Node> childNodes

A list of Node representing the nodes to be logically ORed over in this node.

toString

public @NonNull String toString()

Gets the string representation of OrNode.

The string representation of OrNode is the string representation of OrNode's child nodes joined with "OR", all surrounded by parentheses.