ComparatorNode


@ExperimentalAppSearchApi
public final class ComparatorNode implements Node


Node that represents a numeric search expression between a property and a numeric value.

All numeric search expressions are represented by this Node by passing in a Comparator that represent one of the comparator operators available in the query language, a PropertyPath representing the property, and a numeric value to compare the property against.

This node represents comparators as defined in the Google AIP EBNF Filtering Definition.

Summary

Constants

static final int
EQUALS = 0
static final int
static final int
static final int
static final int

Public constructors

ComparatorNode(
    int comparator,
    @NonNull PropertyPath propertyPath,
    long value
)

Construct a Node representing a numeric search expression between a property and a numeric value.

Public methods

boolean
int

Get the @Comparator used in the comparison.

@NonNull PropertyPath

Get the PropertyPath being compared.

long

Get the numeric value being compared.

int
void
setComparator(int comparator)

Set the @Comparator being used to compare the PropertyPath and value.

void

Set the PropertyPath being compared, i.e. the left side of the comparison.

void
setValue(long value)

Set the numeric value being compared, i.e. the right side of the comparison.

@NonNull String

Get the query string representation of ComparatorNode.

Inherited methods

From androidx.appsearch.ast.Node
@NonNull List<Node>

Get a list of the node's child Nodes.

Constants

EQUALS

Added in 1.1.0-alpha07
public static final int EQUALS = 0

GREATER_EQUALS

Added in 1.1.0-alpha07
public static final int GREATER_EQUALS = 4

GREATER_THAN

Added in 1.1.0-alpha07
public static final int GREATER_THAN = 3

LESS_EQUALS

Added in 1.1.0-alpha07
public static final int LESS_EQUALS = 2

LESS_THAN

Added in 1.1.0-alpha07
public static final int LESS_THAN = 1

Public constructors

ComparatorNode

Added in 1.1.0-alpha07
public ComparatorNode(
    int comparator,
    @NonNull PropertyPath propertyPath,
    long value
)

Construct a Node representing a numeric search expression between a property and a numeric value.

Parameters
int comparator

An IntDef representing what comparison is being made.

@NonNull PropertyPath propertyPath

A PropertyPath that is property being compared i.e. the left hand side of the comparison.

long value

The numeric value being compared i.e. the right hand side of the comparison.

Public methods

equals

public boolean equals(Object o)

getComparator

Added in 1.1.0-alpha07
public int getComparator()

Get the @Comparator used in the comparison.

getPropertyPath

Added in 1.1.0-alpha07
public @NonNull PropertyPath getPropertyPath()

Get the PropertyPath being compared.

I.e. left hand side of the comparison represented by this node.

getValue

Added in 1.1.0-alpha07
public long getValue()

Get the numeric value being compared.

I.e. the right hand side of the comparison represented by this node.

hashCode

public int hashCode()

setComparator

Added in 1.1.0-alpha07
public void setComparator(int comparator)

Set the @Comparator being used to compare the PropertyPath and value.

setPropertyPath

Added in 1.1.0-alpha07
public void setPropertyPath(@NonNull PropertyPath propertyPath)

Set the PropertyPath being compared, i.e. the left side of the comparison.

setValue

Added in 1.1.0-alpha07
public void setValue(long value)

Set the numeric value being compared, i.e. the right side of the comparison.

toString

public @NonNull String toString()

Get the query string representation of ComparatorNode.

The string representation is the string representation of the property path joined from the left to the value being compared with the string representation of the Comparator.