Creating a standard query filter
A standard query
filter represents a named query predicate that you can add to
a query builder result object. You create a standard query filter by
instantiating a new StandardQueryFilter
object. The gw.api.filters
package contains the StandardQueryFilter
class. Its constructor takes two arguments:
- Name
– A
Stringto use as an identifier for the filter. - Predicate – A Gosu block with a query builder predicate method. You must apply the predicate method to a field in the query result that you want to filter. You can use the same predicate methods in standard query filter predicates that you use on queries themselves.
The following Gosu code creates a standard query filter
that can apply to query results that include Address instances. The standard
query filter predicate uses a compare
predicate method on the City
field.
var myQueryFilter = new StandardQueryFilter("myQueryFilter",
\ query -> {query.compare("City", Equals, "Bloomington")})
Note: The package
gw.api.filters contains predefined
standard query filters that you can apply as needed. 