public class QueryOperator
extends java.lang.Object
Represents a OData query operator.
Query operators are typically used within DataQuery.filter
.
QueryOperatorCall
can be constructed using static calls on QueryOperator
or, more conveniently, by chained calls on QueryValue
.
public void queryOperatorExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .filter(QueryOperator.greaterEqual(QueryOperator.multiply(OrderDetail.quantity, OrderDetail.unitPrice), DecimalValue.of(DecimalFunction.fromInt(1000)))); OrderDetail__List details = service.getOrderDetails(query); this.showDetails(details); }
public void queryValueOperatorExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .filter(OrderDetail.quantity.multiply(OrderDetail.unitPrice) .greaterEqual(NorthwindProxyClient.DECIMAL_POSITIVE_1000)); OrderDetail__List details = service.getOrderDetails(query); this.showDetails(details); }
Modifier and Type | Field and Description |
---|---|
static QueryOperatorMap |
operatorMap |
Constructor and Description |
---|
QueryOperator() |
Modifier and Type | Method and Description |
---|---|
static QueryValue |
add(DataValue left,
DataValue right)
Return a deferred call of the OData 'add' arithmetic operator.
|
static QueryFilter |
all(DataValue value,
DataPath lambda,
QueryFilter match)
Return a deferred call of the OData 'all' lambda operator.
|
static QueryFilter |
and(DataValue left,
DataValue right)
Return a deferred call of the OData 'and' logical operator.
|
static QueryFilter |
any(DataValue value,
DataPath lambda,
QueryFilter match)
Return a deferred call of the OData 'any' lambda operator.
|
static QueryValue |
divide(DataValue left,
DataValue right)
Return a deferred call of the OData 'div' arithmetic operator.
|
static QueryFilter |
equal(DataValue left,
DataValue right)
Return a deferred call of the OData 'eq' logical operator.
|
static QueryOperator |
forCode(int code)
Lookup a query operator by code.
|
static QueryOperator |
forName(java.lang.String name)
Lookup a query operator by code.
|
int |
getArity()
Return operator arity (number of arguments).
|
int |
getCode()
Return operator code.
|
java.lang.String |
getName()
Return operator name.
|
int |
getPriority()
Return operator priority.
|
static QueryFilter |
greaterEqual(DataValue left,
DataValue right)
Return a deferred call of the OData 'ge' logical operator.
|
static QueryFilter |
greaterThan(DataValue left,
DataValue right)
Return a deferred call of the OData 'gt' logical operator.
|
static QueryFilter |
has(DataValue value,
EnumValue flags)
Return a deferred call of the OData 'has' operator.
|
static QueryFilter |
lessEqual(DataValue left,
DataValue right)
Return a deferred call of the OData 'le' logical operator.
|
static QueryFilter |
lessThan(DataValue left,
DataValue right)
Return a deferred call of the OData 'lt' logical operator.
|
static QueryValue |
modulo(DataValue left,
DataValue right)
Return a deferred call of the OData 'mod' arithmetic operator.
|
static QueryValue |
multiply(DataValue left,
DataValue right)
Return a deferred call of the OData 'mul' arithmetic operator.
|
static QueryValue |
negate(DataValue value)
Return a deferred call of the OData '-' arithmetic operator.
|
static QueryFilter |
not(DataValue value)
Return a deferred call of the OData 'not' logical operator.
|
static QueryFilter |
notEqual(DataValue left,
DataValue right)
Return a deferred call of the OData 'ne' logical operator.
|
static QueryFilter |
or(DataValue left,
DataValue right)
Return a deferred call of the OData 'or' logical operator.
|
static QueryValue |
subtract(DataValue left,
DataValue right)
Return a deferred call of the OData 'sub' arithmetic operator.
|
java.lang.String |
toString() |
public static final QueryOperatorMap operatorMap
public static QueryValue add(DataValue left, DataValue right)
Return a deferred call of the OData 'add' arithmetic operator.
left
- Left operand.right
- Right operand.public static QueryFilter all(DataValue value, DataPath lambda, QueryFilter match)
Return a deferred call of the OData 'all' lambda operator.
public void allOperatorExample() { NorthwindService service = this.getService(); DataPath p = DataPath.lambda("p"); DataQuery query = new DataQuery() .filter(Category.products.all(p, QueryOperator.greaterThan(p.path(Product.unitPrice), DecimalValue.of(NorthwindProxyClient.DECIMAL_POSITIVE_1)))); Category__List categories = service.getCategories(query); assert categories.length() != 0; }
public void allOperatorExample() { DataService service = this.getService(); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntityType categoryEntityType = categoriesEntitySet.getEntityType(); Property productsProperty = categoryEntityType.getProperty("Products"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType productEntityType = productsEntitySet.getEntityType(); Property unitPriceProperty = productEntityType.getProperty("UnitPrice"); DataPath p = DataPath.lambda("p"); DataQuery query = new DataQuery().from(categoriesEntitySet) .filter(productsProperty.all(p, QueryOperator.greaterThan(p.path(unitPriceProperty), DecimalValue.of(NorthwindClient.DECIMAL_POSITIVE_1)))); EntityValueList categories = service.executeQuery(query).getEntityList(); assert categories.length() != 0; }
value
- Collection value.lambda
- Lambda variable.match
- Query filter.public static QueryFilter and(DataValue left, DataValue right)
Return a deferred call of the OData 'and' logical operator.
left
- Left operand.right
- Right operand.public static QueryFilter any(DataValue value, DataPath lambda, QueryFilter match)
Return a deferred call of the OData 'any' lambda operator.
public void anyOperatorExample() { NorthwindService service = this.getService(); DataPath p = DataPath.lambda("p"); DataQuery query = new DataQuery() .filter(Category.products.any(p, QueryOperator.greaterThan(p.path(Product.unitPrice), DecimalValue.of(NorthwindProxyClient.DECIMAL_POSITIVE_20)))); Category__List categories = service.getCategories(query); assert categories.length() != 0; }
public void anyOperatorExample() { DataService service = this.getService(); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntityType categoryEntityType = categoriesEntitySet.getEntityType(); Property productsProperty = categoryEntityType.getProperty("Products"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType productEntityType = productsEntitySet.getEntityType(); Property unitPriceProperty = productEntityType.getProperty("UnitPrice"); DataPath p = DataPath.lambda("p"); DataQuery query = new DataQuery().from(categoriesEntitySet) .filter(productsProperty.any(p, QueryOperator.greaterThan(p.path(unitPriceProperty), DecimalValue.of(NorthwindClient.DECIMAL_POSITIVE_20)))); EntityValueList categories = service.executeQuery(query).getEntityList(); assert categories.length() != 0; }
value
- Collection value.lambda
- Lambda variable.match
- Query filter.public static QueryValue divide(DataValue left, DataValue right)
Return a deferred call of the OData 'div' arithmetic operator.
left
- Left operand.right
- Right operand.public static QueryFilter equal(DataValue left, DataValue right)
Return a deferred call of the OData 'eq' logical operator.
left
- (nullable) Left operand.right
- (nullable) Right operand.public static QueryOperator forCode(int code)
Lookup a query operator by code.
constants.
code
- Operator code.public static QueryOperator forName(java.lang.String name)
Lookup a query operator by code.
DataQueryException
if name
is not the name of a known query operator.
name
- Operator name.public int getArity()
Return operator arity (number of arguments).
public int getCode()
Return operator code.
public java.lang.String getName()
Return operator name.
public int getPriority()
Return operator priority.
public static QueryFilter greaterEqual(DataValue left, DataValue right)
Return a deferred call of the OData 'ge' logical operator.
left
- Left operand.right
- Right operand.public static QueryFilter greaterThan(DataValue left, DataValue right)
Return a deferred call of the OData 'gt' logical operator.
left
- Left operand.right
- Right operand.public static QueryFilter has(DataValue value, EnumValue flags)
Return a deferred call of the OData 'has' operator.
value
- Enum value to be tested to see if flag
is set.flags
- Flag(s) to test for.public static QueryFilter lessEqual(DataValue left, DataValue right)
Return a deferred call of the OData 'le' logical operator.
left
- Left operand.right
- Right operand.public static QueryFilter lessThan(DataValue left, DataValue right)
Return a deferred call of the OData 'lt' logical operator.
left
- Left operand.right
- Right operand.public static QueryValue modulo(DataValue left, DataValue right)
Return a deferred call of the OData 'mod' arithmetic operator.
left
- Left operand.right
- Right operand.public static QueryValue multiply(DataValue left, DataValue right)
Return a deferred call of the OData 'mul' arithmetic operator.
left
- Left operand.right
- Right operand.public static QueryValue negate(DataValue value)
Return a deferred call of the OData '-' arithmetic operator.
value
- Numeric value.public static QueryFilter not(DataValue value)
Return a deferred call of the OData 'not' logical operator.
value
- Logical value.public static QueryFilter notEqual(DataValue left, DataValue right)
Return a deferred call of the OData 'ne' logical operator.
left
- (nullable) Left operand.right
- (nullable) Right operand.public static QueryFilter or(DataValue left, DataValue right)
Return a deferred call of the OData 'or' logical operator.
left
- Left operand.right
- Right operand.public static QueryValue subtract(DataValue left, DataValue right)
Return a deferred call of the OData 'sub' arithmetic operator.
left
- Left operand.right
- Right operand.public java.lang.String toString()
toString
in class java.lang.Object