public class QueryFilter extends DataValue
Encapsulates the boolean value of an OData logical operator.
Used to wrap the results of logical QueryOperator in a type-safe manner.
public void queryWithFilterExample() {
NorthwindService service = this.getService();
DataQuery query = new DataQuery()
.select(Customer.customerID, Customer.companyName, Customer.contactName)
.filter(Customer.country.equal("Germany")
.and(Customer.contactName.greaterEqual("N")));
Customer__List customers = service.getCustomers(query);
this.showCustomers(customers);
}
public void queryWithFilterExample() {
DataService service = this.getService();
EntitySet customersEntitySet = service.getEntitySet("Customers");
EntityType customerEntityType = customersEntitySet.getEntityType();
Property customerIDProperty = customerEntityType.getProperty("CustomerID");
Property companyNameProperty = customerEntityType.getProperty("CompanyName");
Property contactNameProperty = customerEntityType.getProperty("ContactName");
Property countryProperty = customerEntityType.getProperty("Country");
DataQuery query = new DataQuery()
.select(customerIDProperty, companyNameProperty, contactNameProperty)
.from(customersEntitySet)
.filter(countryProperty.equal("Germany")
.and(contactNameProperty.greaterEqual("N")));
EntityValueList customers = service.executeQuery(query).getEntityList();
this.showCustomers(customers);
}
| Constructor and Description |
|---|
QueryFilter() |
| Modifier and Type | Method and Description |
|---|---|
QueryFilter |
and(DataValue filter)
Return an application of the OData 'and' logical operator to
this and filter. |
DataValue |
find(Property property,
int operatorCode)
Return (nullable) A top-level comparison value for the specified property and operator.
|
static QueryFilter |
from(DataValue value)
Construct a query filter by wrapping a boolean value, so it can be used by
DataQuery.queryFilter or DataQuery.where. |
DataType |
getDataType()
Return data type with a
DataType.code of DataType.QUERY_FILTER. |
DataValue |
getValue()
Return the wrapped value which is expected to resolve to a boolean value during query execution.
|
QueryFilter |
not()
Return an application of the OData 'not' logical operator to
this. |
QueryFilter |
or(DataValue filter)
Return an application of the OData 'or' logical operator to
this and filter. |
void |
setValue(DataValue value)
Set the wrapped value which is expected to resolve to a boolean value during query execution.
|
java.lang.String |
toString()
Convert this data value to a string.
|
cloneMutable, equals, getTypeCode, hashCodepublic QueryFilter and(DataValue filter)
Return an application of the OData 'and' logical operator to this and filter.
This is a convenience wrapper for QueryOperator.and which allows method chaining.
filter - To be and'ed with this.this and filter.public DataValue find(Property property, int operatorCode)
Return (nullable) A top-level comparison value for the specified property and operator. Otherwise null.
If this filter contains a top-level (possibly and'ed) condition for the specified property and operator, then return the comparison value.
property - Property to match.operatorCode - Operator to match.public static QueryFilter from(DataValue value)
Construct a query filter by wrapping a boolean value, so it can be used by DataQuery.queryFilter or DataQuery.where.
value - A boolean value.public DataType getDataType()
Return data type with a DataType.code of DataType.QUERY_FILTER.
getDataType in class DataValueDataType.code of DataType.QUERY_FILTER.public DataValue getValue()
Return the wrapped value which is expected to resolve to a boolean value during query execution.
public QueryFilter not()
Return an application of the OData 'not' logical operator to this.
This is a convenience wrapper for QueryOperator.not which allows method chaining.
this.public QueryFilter or(DataValue filter)
Return an application of the OData 'or' logical operator to this and filter.
This is a convenience wrapper for QueryOperator.or which allows method chaining.
filter - To be or'ed with this.this and filter.public void setValue(DataValue value)
Set the wrapped value which is expected to resolve to a boolean value during query execution.
value - The wrapped value which is expected to resolve to a boolean value during query execution.public java.lang.String toString()
Convert this data value to a string.
If the QueryFilter.dataType is defined by XML Schema Part 2: Datatypes, then the corresponding lexical format is used.
JSON format is used for structured values (arrays and objects).