# ComparatorNode

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/ComparatorNode.java+class:androidx.appsearch.ast.operators.ComparatorNode) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


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

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/appsearch/ast/Node` that represents a numeric search expression between a property and a numeric value.

All numeric search expressions are represented by this `https://developer.android.com/reference/androidx/appsearch/ast/Node` by passing in a `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode.Comparator` that represent one of the comparator operators available in the query language, a `https://developer.android.com/reference/androidx/appsearch/app/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](https://google.aip.dev/assets/misc/ebnf-filtering.txt).

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#EQUALS() = 0` |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#GREATER_EQUALS() = 4` |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#GREATER_THAN() = 3` |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#LESS_EQUALS() = 2` |
| `static final int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#LESS_THAN() = 1` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#ComparatorNode(int,androidx.appsearch.app.PropertyPath,long)( int comparator, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/PropertyPath propertyPath, long value )` Construct a `https://developer.android.com/reference/androidx/appsearch/ast/Node` representing a numeric search expression between a property and a numeric value. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html o)` |
| `int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#getComparator()()` Get the `@Comparator` used in the comparison. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#getPropertyPath()()` Get the `PropertyPath` being compared. |
| `long` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#getValue()()` Get the numeric value being compared. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#hashCode()()` |
| `void` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#setComparator(int)(int comparator)` Set the `@Comparator` being used to compare the `PropertyPath` and value. |
| `void` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#setPropertyPath(androidx.appsearch.app.PropertyPath)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/PropertyPath propertyPath)` Set the `PropertyPath` being compared, i.e. the left side of the comparison. |
| `void` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#setValue(long)(long value)` Set the numeric value being compared, i.e. the right side of the comparison. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode#toString()()` Get the query string representation of `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode`. |

| ### Inherited methods |
|---|
| From [androidx.appsearch.ast.Node](https://developer.android.com/reference/androidx/appsearch/ast/Node) |---|---| | `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html 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/Node#getChildren()()` Get a list of the node's child `https://developer.android.com/reference/androidx/appsearch/ast/Node`s. | |

## Constants

### EQUALS

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

```
public static final int EQUALS = 0
```

### GREATER_EQUALS

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

```
public static final int GREATER_EQUALS = 4
```

### GREATER_THAN

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

```
public static final int GREATER_THAN = 3
```

### LESS_EQUALS

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

```
public static final int LESS_EQUALS = 2
```

### LESS_THAN

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

```
public static final int LESS_THAN = 1
```

## Public constructors

### ComparatorNode

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

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

Construct a `https://developer.android.com/reference/androidx/appsearch/ast/Node` representing a numeric search expression between a property and a numeric value.

| Parameters |
|---|---|
| `int comparator` | An `IntDef` representing what comparison is being made. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/PropertyPath propertyPath` | A `https://developer.android.com/reference/androidx/appsearch/app/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](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public int getComparator()
```

Get the `@Comparator` used in the comparison.

### getPropertyPath

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

```
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](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
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](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public void setComparator(int comparator)
```

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

### setPropertyPath

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

```
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](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
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 `https://developer.android.com/reference/androidx/appsearch/ast/operators/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 `https://developer.android.com/reference/androidx/appsearch/ast/operators/ComparatorNode.Comparator`.