Class Field
- java.lang.Object
-
- com.apple.foundationdb.record.query.expressions.Field
-
@API(MAINTAINED) public class Field extends Object
Class that provides context for asserting about a field value.oneOfThem()
andmatches(QueryComponent)
allow you to create other components, while the remaining functions allow you to match on the value of the associated field directly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Field.OneOfThemEmptyMode
How an empty / unset repeated field should be handled.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryComponent
equalsParameter(String param)
Checks if the field has a value equal to the given parameter.QueryComponent
equalsValue(Object comparand)
Checks if the field has a value equal to the given comparand.QueryComponent
greaterThan(Object comparand)
Checks if the field has a value greater than the given comparand.QueryComponent
greaterThanOrEquals(Object comparand)
Checks if the field has a value greater than or equal to the given comparand.QueryComponent
in(String param)
Query where the value of this field is in the list that is bound to the given param.QueryComponent
in(List<?> comparand)
Query where the value of this field is in the given list.QueryComponent
isEmpty()
Returns true if the repeated field does not have any occurrences.QueryComponent
isNull()
Returns true if the field has not been set and uses the default value.QueryComponent
lessThan(Object comparand)
Checks if the field has a value less than the given comparand.QueryComponent
lessThanOrEquals(Object comparand)
Checks if the field has a value less than or equal to the given comparand.QueryComponent
mapMatches(Function<Field,QueryComponent> keyMatcher, Function<Field,QueryComponent> valueMatcher)
Matchmap
field entries.QueryComponent
matches(QueryComponent child)
If the associated field is a submessage, this allows you to match against the fields within that submessage.QueryComponent
notEmpty()
Returns true if the repeated field has occurrences.QueryComponent
notEquals(Object comparand)
Checks if the field has a value not equal to the given comparand.QueryComponent
notNull()
Returns true if the field does not use the default value.OneOfThem
oneOfThem()
If the associated field is a repeated one, this allows you to match against one of the repeated values.OneOfThem
oneOfThem(Field.OneOfThemEmptyMode emptyMode)
If the associated field is a repeated one, this allows you to match against one of the repeated values.QueryComponent
startsWith(String comparand)
Checks if the field starts with the given string.Text
text()
Query where the value of this field matches some property when performing a full-text search.Text
text(String tokenizerName)
Query where the value of this field matches some property when performing a full-text search.Text
text(String tokenizerName, String defaultTokenizerName)
Query where the value of this field matches some property when performing a full-text search.
-
-
-
Method Detail
-
matches
@Nonnull public QueryComponent matches(@Nonnull QueryComponent child)
If the associated field is a submessage, this allows you to match against the fields within that submessage. The child is evaluated and validated in the context of this field, not the record containing this field.- Parameters:
child
- a component asserting about the content of the submessage in this field- Returns:
- a new component ready for evaluation
-
oneOfThem
@Nonnull public OneOfThem oneOfThem()
If the associated field is a repeated one, this allows you to match against one of the repeated values. The record will be returned if any one of the values returnstrue
. The same record may be returned more than once. If the repeated field is empty, the match result will be UNKNOWN.- Returns:
- an OneOfThem that can have further assertions called on it about the value of the given field
-
oneOfThem
@Nonnull public OneOfThem oneOfThem(Field.OneOfThemEmptyMode emptyMode)
If the associated field is a repeated one, this allows you to match against one of the repeated values. The record will be returned if any one of the values returnstrue
. The same record may be returned more than once.- Parameters:
emptyMode
- whether an empty repeated field should cause an UNKNOWN result instead of failing to match any (and so returning FALSE)- Returns:
- an OneOfThem that can have further assertions called on it about the value of the given field
-
equalsValue
@Nonnull public QueryComponent equalsValue(@Nonnull Object comparand)
Checks if the field has a value equal to the given comparand. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
notEquals
@Nonnull public QueryComponent notEquals(@Nonnull Object comparand)
Checks if the field has a value not equal to the given comparand. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
greaterThan
@Nonnull public QueryComponent greaterThan(@Nonnull Object comparand)
Checks if the field has a value greater than the given comparand. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
greaterThanOrEquals
@Nonnull public QueryComponent greaterThanOrEquals(@Nonnull Object comparand)
Checks if the field has a value greater than or equal to the given comparand. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
lessThan
@Nonnull public QueryComponent lessThan(@Nonnull Object comparand)
Checks if the field has a value less than the given comparand. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
lessThanOrEquals
@Nonnull public QueryComponent lessThanOrEquals(@Nonnull Object comparand)
Checks if the field has a value less than or equal to the given comparand. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
startsWith
@Nonnull public QueryComponent startsWith(@Nonnull String comparand)
Checks if the field starts with the given string. Requires that the field contains a string. Evaluates to null if the field does not have a value.- Parameters:
comparand
- the object to compare with the value in the field- Returns:
- a new component for doing the actual evaluation
-
isNull
@Nonnull public QueryComponent isNull()
Returns true if the field has not been set and uses the default value.- Returns:
- a new component for doing the actual evaluation
-
notNull
@Nonnull public QueryComponent notNull()
Returns true if the field does not use the default value.- Returns:
- a new component for doing the actual evaluation
-
isEmpty
@Nonnull public QueryComponent isEmpty()
Returns true if the repeated field does not have any occurrences.- Returns:
- a new component for doing the actual evaluation
-
notEmpty
@Nonnull public QueryComponent notEmpty()
Returns true if the repeated field has occurrences.- Returns:
- a new component for doing the actual evaluation
-
in
@Nonnull public QueryComponent in(@Nonnull List<?> comparand)
Query where the value of this field is in the given list.- Parameters:
comparand
- a list of elements- Returns:
- a new component for doing the actual evaluation
-
in
@Nonnull public QueryComponent in(@Nonnull String param)
Query where the value of this field is in the list that is bound to the given param.- Parameters:
param
- a param that will be bound to a list in the execution context- Returns:
- a new component for doing the actual evaluation
-
text
@Nonnull public Text text()
Query where the value of this field matches some property when performing a full-text search. It does not specify any tokenizer information, so it is assumed that any tokenizer is acceptable for parsing query string (if not already tokenized) or to parse the record's text or to match against an index. If an index is used during query execution, then it is guaranteed that the same tokenizer that was used to tokenize the index is used to tokenize the query string (if not already tokenized).- Returns:
- an intermediate object to use to select the appropriate predicate
-
text
@Nonnull public Text text(@Nullable String tokenizerName)
Query where the value of this field matches some property when performing a full-text search. IftokenizerName
is notnull
, then this will use that tokenizer to tokenize the query string (if not already tokenized) and to parse the record's text. If an index is used, then it is guaranteed that the index uses this same tokenizer. IftokenizerName
isnull
, then this behaves the same astext()
.- Parameters:
tokenizerName
- the name of the tokenizer to use to tokenize the record and (if necessary) the query string- Returns:
- an intermediate object to use to select the appropriate predicate
-
text
@Nonnull public Text text(@Nullable String tokenizerName, @Nullable String defaultTokenizerName)
Query where the value of this field matches some property when performing a full-text search. IftokenizerName
is notnull
, then this will use that tokenizer to tokenize the query string (if not already tokenized) and to parse the record's text. If an index is used, then it is guaranteed that the index uses this same tokenizer. IftokenizerName
isnull
, then this behaves the same astext()
except that ifdefaultTokenizerName
is notnull
, then it will use that tokenizer to tokenize the document and query string (if no index is available) instead of the normal default tokenizer,DefaultTextTokenizer
.- Parameters:
tokenizerName
- the name of the tokenizer to use to tokenize the record and (if necessary) the query stringdefaultTokenizerName
- the name of the tokenizer to use iftokenizerName
isnull
and no index can be found to satisfy the query- Returns:
- an intermediate object to use to select the appropriate predicate
-
equalsParameter
@Nonnull public QueryComponent equalsParameter(@Nonnull String param)
Checks if the field has a value equal to the given parameter. Evaluates to null if the field does not have a value.- Parameters:
param
- the name of the parameter- Returns:
- a new component for doing the actual evaluation
-
mapMatches
@Nonnull public QueryComponent mapMatches(@Nullable Function<Field,QueryComponent> keyMatcher, @Nullable Function<Field,QueryComponent> valueMatcher)
Matchmap
field entries.Query.field("map_field").mapMatches(k -> k.equals("akey"), v -> v.greaterThan(10))
- Parameters:
keyMatcher
- a function to apply to the keyField
ornull
not to restrict the keyvalueMatcher
- a function to apply to the valueField
ornull
not to restrict the value- Returns:
- a new component that will return the record if the map field has an entry matching the key and value criteria
-
-