Filter

public class Filter


A Filter represents a restriction on one or more field values and can be used to refine the results of a Query.

Summary

Public constructors

Public methods

static @NonNull Filter
and(Filter[] filters)

Creates a new filter that is a conjunction of the given filters.

static @NonNull Filter

Creates a new filter for checking that the given array field contains the given value.

static @NonNull Filter

Creates a new filter for checking that the given array field contains the given value.

static @NonNull Filter

Creates a new filter for checking that the given array field contains any of the given values.

static @NonNull Filter
arrayContainsAny(
    @NonNull FieldPath fieldPath,
    @NonNull List<Object> values
)

Creates a new filter for checking that the given array field contains any of the given values.

static @NonNull Filter
equalTo(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is equal to the given value.

static @NonNull Filter
equalTo(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is equal to the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is greater than the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is greater than the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is greater than or equal to the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is greater than or equal to the given value.

static @NonNull Filter
inArray(@NonNull String field, @NonNull List<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

static @NonNull Filter
inArray(@NonNull FieldPath fieldPath, @NonNull List<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

static @NonNull Filter

Creates a new filter for checking that the given field is less than the given value.

static @NonNull Filter
lessThan(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is less than the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is less than or equal to the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is less than or equal to the given value.

static @NonNull Filter

Creates a new filter for checking that the given field is not equal to the given value.

static @NonNull Filter
notEqualTo(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is not equal to the given value.

static @NonNull Filter

Creates a new filter for checking that the given field does not equal any of the given values.

static @NonNull Filter
notInArray(@NonNull FieldPath fieldPath, @NonNull List<Object> values)

Creates a new filter for checking that the given field does not equal any of the given values.

static @NonNull Filter
or(Filter[] filters)

Creates a new filter that is a disjunction of the given filters.

Public constructors

Filter

public Filter()

Public methods

and

public static @NonNull Filter and(Filter[] filters)

Creates a new filter that is a conjunction of the given filters. A conjunction filter includes a document if it satisfies all of the given filters.

Parameters
Filter[] filters

The list of filters to perform a conjunction for.

Returns
@NonNull Filter

The newly created filter.

arrayContains

public static @NonNull Filter arrayContains(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given array field contains the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

arrayContains

public static @NonNull Filter arrayContains(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given array field contains the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

arrayContainsAny

public static @NonNull Filter arrayContainsAny(@NonNull String field, @NonNull List<Object> values)

Creates a new filter for checking that the given array field contains any of the given values.

Parameters
@NonNull String field

The field used for the filter.

@NonNull List<Object> values

The list of values used for the filter.

Returns
@NonNull Filter

The newly created filter.

arrayContainsAny

public static @NonNull Filter arrayContainsAny(
    @NonNull FieldPath fieldPath,
    @NonNull List<Object> values
)

Creates a new filter for checking that the given array field contains any of the given values.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@NonNull List<Object> values

The list of values used for the filter.

Returns
@NonNull Filter

The newly created filter.

equalTo

public static @NonNull Filter equalTo(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is equal to the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

equalTo

public static @NonNull Filter equalTo(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is equal to the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

greaterThan

public static @NonNull Filter greaterThan(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is greater than the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

greaterThan

public static @NonNull Filter greaterThan(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is greater than the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

greaterThanOrEqualTo

public static @NonNull Filter greaterThanOrEqualTo(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is greater than or equal to the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

greaterThanOrEqualTo

public static @NonNull Filter greaterThanOrEqualTo(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is greater than or equal to the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

inArray

public static @NonNull Filter inArray(@NonNull String field, @NonNull List<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

Parameters
@NonNull String field

The field used for the filter.

@NonNull List<Object> values

The list of values used for the filter.

Returns
@NonNull Filter

The newly created filter.

inArray

public static @NonNull Filter inArray(@NonNull FieldPath fieldPath, @NonNull List<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@NonNull List<Object> values

The list of values used for the filter.

Returns
@NonNull Filter

The newly created filter.

lessThan

public static @NonNull Filter lessThan(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is less than the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

lessThan

public static @NonNull Filter lessThan(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is less than the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

lessThanOrEqualTo

public static @NonNull Filter lessThanOrEqualTo(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is less than or equal to the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

lessThanOrEqualTo

public static @NonNull Filter lessThanOrEqualTo(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is less than or equal to the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

notEqualTo

public static @NonNull Filter notEqualTo(@NonNull String field, @Nullable Object value)

Creates a new filter for checking that the given field is not equal to the given value.

Parameters
@NonNull String field

The field used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

notEqualTo

public static @NonNull Filter notEqualTo(@NonNull FieldPath fieldPath, @Nullable Object value)

Creates a new filter for checking that the given field is not equal to the given value.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@Nullable Object value

The value used for the filter.

Returns
@NonNull Filter

The newly created filter.

notInArray

public static @NonNull Filter notInArray(@NonNull String field, @NonNull List<Object> values)

Creates a new filter for checking that the given field does not equal any of the given values.

Parameters
@NonNull String field

The field path used for the filter.

@NonNull List<Object> values

The list of values used for the filter.

Returns
@NonNull Filter

The newly created filter.

notInArray

public static @NonNull Filter notInArray(@NonNull FieldPath fieldPath, @NonNull List<Object> values)

Creates a new filter for checking that the given field does not equal any of the given values.

Parameters
@NonNull FieldPath fieldPath

The field path used for the filter.

@NonNull List<Object> values

The list of values used for the filter.

Returns
@NonNull Filter

The newly created filter.

or

public static @NonNull Filter or(Filter[] filters)

Creates a new filter that is a disjunction of the given filters. A disjunction filter includes a document if it satisfies any of the given filters.

Parameters
Filter[] filters

The list of filters to perform a disjunction for.

Returns
@NonNull Filter

The newly created filter.