public class Criteria extends Object implements CriteriaDefinition
Criteria.where method improves readability.| Modifier and Type | Class and Description |
|---|---|
static interface |
Criteria.BitwiseCriteriaOperators
MongoDB specific bitwise query
operators like
$bitsAllClear, $bitsAllSet,... for usage with bits() and Query. |
| Modifier | Constructor and Description |
|---|---|
|
Criteria() |
protected |
Criteria(List<Criteria> criteriaChain,
String key) |
|
Criteria(String key) |
| Modifier and Type | Method and Description |
|---|---|
Criteria |
alike(Example<?> sample)
Creates a criterion using the given object as a pattern.
|
Criteria |
all(Collection<?> values)
Creates a criterion using the $all operator.
|
Criteria |
all(Object... values)
Creates a criterion using the $all operator.
|
Criteria |
and(String key)
Static factory method to create a Criteria using the provided key
|
Criteria |
andDocumentStructureMatches(MongoJsonSchema schema)
Creates a criterion (
$jsonSchema) matching documents against a given structure defined by the
MongoJsonSchema. |
Criteria |
andOperator(Collection<Criteria> criteria)
Creates a criteria using the
$and operator for all of the provided criteria. |
Criteria |
andOperator(Criteria... criteria)
Creates a criteria using the
$and operator for all of the provided criteria. |
Criteria.BitwiseCriteriaOperators |
bits()
Use
Criteria.BitwiseCriteriaOperators as gateway to create a criterion using one of the
bitwise operators like
$bitsAllClear. |
static Criteria |
byExample(Example<?> example)
Static factory method to create a
Criteria matching an example object. |
static Criteria |
byExample(Object example)
Static factory method to create a
Criteria matching an example object. |
Criteria |
elemMatch(Criteria criteria)
Creates a criterion using the $elemMatch operator
|
boolean |
equals(Object obj) |
Criteria |
exists(boolean value)
Creates a criterion using the $exists operator.
|
org.bson.Document |
getCriteriaObject()
Get
Document representation. |
String |
getKey()
Get the identifying key.
|
protected org.bson.Document |
getSingleCriteriaObject() |
Criteria |
gt(Object value)
Creates a criterion using the $gt operator.
|
Criteria |
gte(Object value)
Creates a criterion using the $gte operator.
|
int |
hashCode() |
Criteria |
in(Collection<?> values)
Creates a criterion using the $in operator.
|
Criteria |
in(Object... values)
Creates a criterion using the $in operator.
|
Criteria |
intersects(GeoJson geoJson)
Creates criterion using
$geoIntersects operator which matches intersections of the given geoJson
structure and the documents one. |
Criteria |
is(Object value)
Creates a criterion using equality
|
Criteria |
isNull()
Creates a criterion using null equality comparison which matches documents that either contain the item
field whose value is null or that do not contain the item field.
|
Criteria |
isNullValue()
Creates a criterion using a
BsonType comparison which matches only documents that contain the item
field whose value is equal to BsonType.NULL. |
Criteria |
lt(Object value)
Creates a criterion using the $lt operator.
|
Criteria |
lte(Object value)
Creates a criterion using the $lte operator.
|
static Criteria |
matchingDocumentStructure(MongoJsonSchema schema)
Static factory method to create a
Criteria matching documents against a given structure defined by the
MongoJsonSchema using ($jsonSchema) operator. |
Criteria |
maxDistance(double maxDistance)
Creates a geo-spatial criterion using a $maxDistance operation, for use with $near
|
Criteria |
minDistance(double minDistance)
Creates a geospatial criterion using a $minDistance operation, for use with $near or
$nearSphere.
|
Criteria |
mod(Number value,
Number remainder)
Creates a criterion using the $mod operator.
|
Criteria |
ne(Object value)
Creates a criterion using the $ne operator.
|
Criteria |
near(Point point)
Creates a geospatial criterion using a $near operation.
|
Criteria |
nearSphere(Point point)
Creates a geospatial criterion using a $nearSphere operation.
|
Criteria |
nin(Collection<?> values)
Creates a criterion using the $nin operator.
|
Criteria |
nin(Object... values)
Creates a criterion using the $nin operator.
|
Criteria |
norOperator(Collection<Criteria> criteria)
Creates a criteria using the
$nor operator for all of the provided criteria. |
Criteria |
norOperator(Criteria... criteria)
Creates a criteria using the
$nor operator for all of the provided criteria. |
Criteria |
not()
Creates a criterion using the $not meta operator which affects the clause directly following
|
Criteria |
orOperator(Collection<Criteria> criteria)
Creates a criteria using the
$or operator for all of the provided criteria. |
Criteria |
orOperator(Criteria... criteria)
Creates a criteria using the
$or operator for all of the provided criteria. |
Criteria |
regex(org.bson.BsonRegularExpression regex)
Use a MongoDB native
BsonRegularExpression. |
Criteria |
regex(Pattern pattern)
Syntactical sugar for
is(Object) making obvious that we create a regex predicate. |
Criteria |
regex(String regex)
Creates a criterion using a $regex operator.
|
Criteria |
regex(String regex,
String options)
Creates a criterion using a $regex and $options operator.
|
Criteria |
sampleRate(double sampleRate)
Creates a criterion using the $sampleRate operator.
|
Criteria |
size(int size)
Creates a criterion using the $size operator.
|
Criteria |
type(Collection<JsonSchemaObject.Type> types)
Creates a criterion using the $type operator.
|
Criteria |
type(int typeNumber)
Creates a criterion using the $type operator.
|
Criteria |
type(JsonSchemaObject.Type... types)
Creates a criterion using the $type operator.
|
static Criteria |
where(String key)
Static factory method to create a Criteria using the provided key
|
Criteria |
within(Shape shape)
Creates a geospatial criterion using a $geoWithin operation.
|
Criteria |
withinSphere(Circle circle)
Creates a geospatial criterion using a $geoWithin $centerSphere operation.
|
public Criteria()
public Criteria(String key)
public static Criteria where(String key)
key - the property or field name.Criteria.public static Criteria byExample(Object example)
Criteria matching an example object.example - must not be null.Criteria.alike(Example)public static Criteria byExample(Example<?> example)
Criteria matching an example object. Example uses typed matching restricting it to probe assignable types. For example, when
sticking with the default type key (_class), the query has restrictions such as
_class : { $in : [com.acme.Person] } . UntypedExampleMatcher with
Example.of(Object, org.springframework.data.domain.ExampleMatcher).example - must not be null.Criteria.alike(Example)public static Criteria matchingDocumentStructure(MongoJsonSchema schema)
Criteria matching documents against a given structure defined by the
MongoJsonSchema using ($jsonSchema) operator.schema - must not be null.public Criteria and(String key)
Criteria.public Criteria is(@Nullable Object value)
value - can be null.public Criteria isNull()
isNullValue() to only query for documents that contain the field whose value is equal to
BsonType.NULL. exists(boolean) to query for documents that do (not) contain the field.public Criteria isNullValue()
BsonType comparison which matches only documents that contain the item
field whose value is equal to BsonType.NULL.
isNull() to query for documents that contain the field with a null value or do not contain the
field at all. exists(boolean) to query for documents that do (not) contain the field.public Criteria ne(@Nullable Object value)
value - can be null.public Criteria lt(Object value)
value - must not be null.public Criteria lte(Object value)
value - must not be null.public Criteria gt(Object value)
value - must not be null.public Criteria gte(Object value)
value - can be null.public Criteria in(Object... values)
values - the values to match againstpublic Criteria in(Collection<?> values)
values - the collection containing the values to match againstpublic Criteria nin(Object... values)
values - public Criteria nin(Collection<?> values)
values - must not be null.public Criteria mod(Number value, Number remainder)
value - must not be null.remainder - must not be null.public Criteria all(Object... values)
values - must not be null.public Criteria all(Collection<?> values)
values - must not be null.public Criteria size(int size)
size - public Criteria exists(boolean value)
value - public Criteria sampleRate(double sampleRate)
sampleRate - sample rate to determine number of documents to be randomly selected from the input. Must be
between 0 and 1.public Criteria type(int typeNumber)
typeNumber - public Criteria type(JsonSchemaObject.Type... types)
types - must not be null.public Criteria type(Collection<JsonSchemaObject.Type> types)
types - must not be null.public Criteria not()
public Criteria regex(String regex)
regex - must not be null.public Criteria regex(String regex, @Nullable String options)
regex - must not be null.options - can be null.public Criteria regex(Pattern pattern)
is(Object) making obvious that we create a regex predicate.pattern - must not be null.public Criteria regex(org.bson.BsonRegularExpression regex)
BsonRegularExpression.regex - must not be null.public Criteria withinSphere(Circle circle)
circle - must not be nullpublic Criteria within(Shape shape)
shape - must not be null.public Criteria near(Point point)
point - must not be nullpublic Criteria nearSphere(Point point)
point - must not be nullpublic Criteria intersects(GeoJson geoJson)
$geoIntersects operator which matches intersections of the given geoJson
structure and the documents one. Requires MongoDB 2.4 or better.geoJson - must not be null.public Criteria maxDistance(double maxDistance)
maxDistance - public Criteria minDistance(double minDistance)
minDistance - public Criteria elemMatch(Criteria criteria)
criteria - must not be null.public Criteria alike(Example<?> sample)
sample - must not be null.public Criteria andDocumentStructureMatches(MongoJsonSchema schema)
$jsonSchema) matching documents against a given structure defined by the
MongoJsonSchema. $jsonSchema cannot be used on field/property level but defines the whole document
structure. Please use
MongoJsonSchema.MongoJsonSchemaBuilder.properties(JsonSchemaProperty...)
to specify nested fields or query them using the $type operator.schema - must not be null.public Criteria.BitwiseCriteriaOperators bits()
Criteria.BitwiseCriteriaOperators as gateway to create a criterion using one of the
bitwise operators like
$bitsAllClear.Criteria.BitwiseCriteriaOperators. Never null.public Criteria orOperator(Criteria... criteria)
$or operator for all of the provided criteria.
Note that MongoDB doesn't support an $nor operator to be wrapped in a $not operator.
criteria - must not be null.IllegalArgumentException - if this method follows a not() call directly.public Criteria orOperator(Collection<Criteria> criteria)
$or operator for all of the provided criteria.
Note that MongoDB doesn't support an $nor operator to be wrapped in a $not operator.
criteria - must not be null.IllegalArgumentException - if this method follows a not() call directly.public Criteria norOperator(Criteria... criteria)
$nor operator for all of the provided criteria.
Note that MongoDB doesn't support an $nor operator to be wrapped in a $not operator.
criteria - must not be null.IllegalArgumentException - if this method follows a not() call directly.public Criteria norOperator(Collection<Criteria> criteria)
$nor operator for all of the provided criteria.
Note that MongoDB doesn't support an $nor operator to be wrapped in a $not operator.
criteria - must not be null.IllegalArgumentException - if this method follows a not() call directly.public Criteria andOperator(Criteria... criteria)
$and operator for all of the provided criteria.
Note that MongoDB doesn't support an $and operator to be wrapped in a $not operator.
criteria - must not be null.IllegalArgumentException - if this method follows a not() call directly.public Criteria andOperator(Collection<Criteria> criteria)
$and operator for all of the provided criteria.
Note that MongoDB doesn't support an $and operator to be wrapped in a $not operator.
criteria - must not be null.IllegalArgumentException - if this method follows a not() call directly.@Nullable public String getKey()
CriteriaDefinitiongetKey in interface CriteriaDefinitionpublic org.bson.Document getCriteriaObject()
CriteriaDefinitionDocument representation.getCriteriaObject in interface CriteriaDefinitionprotected org.bson.Document getSingleCriteriaObject()
Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.