Filter
import io.skipcheck.tm1.client.odata.Filter; A $filter expression, built from ODataProperty comparisons and the
canonical functions TM1 supports:
Filter numericQ = Filter.and(Filter.startsWith(Element.NAME, "Q"),
Element.TYPE.eq(ODataLiterals.enumMember("ibm.tm1.api.v1.ElementType", "Numeric")));
// (startswith(Name,'Q') and (Type eq ibm.tm1.api.v1.ElementType'Numeric'))
Filter hasRegion = Filter.any("Hierarchies", "h", (h) -> h.nav("Name").eq("Region"));
// Hierarchies/any(h:h/Name eq 'Region')
Every binary expression is parenthesized, so precedence never depends on how a filter
was composed. Values are written as OData literals (ODataLiterals.of); the
whole expression is percent-encoded once, when the query is rendered. raw
takes any expression as is, and is parenthesized when it's combined with others.
Note that TM1 compares names in $filter case- and space-sensitively, while
keyed access ignores both. To find one object by name, use its key rather than a
filter.
Members
raw static | An expression written by hand, used as is. |
and static | All of the given filters. |
or static | Any of the given filters. |
not static | not filter. |
startsWith static | startswith(property,'prefix'). |
endsWith static | endswith(property,'suffix'). |
contains static | contains(property,'text'). |
any static | True if any member of a collection matches. |
all static | True if every member of a collection matches. |
in static | property in (a,b,c). |
toString | The expression, unencoded, e.g. |
equals | |
hashCode |
raw
staticstatic Filter raw(String expression)and
staticstatic Filter and(Filter... filters)All of the given filters.
Parameters
filters- the filters, at least one
Returns
- the filters joined with
and, or the filter itself if there's only one
or
staticstatic Filter or(Filter... filters)Any of the given filters.
Parameters
filters- the filters, at least one
Returns
- the filters joined with
or, or the filter itself if there's only one
not
staticstatic Filter not(Filter filter) not filter.
Parameters
filter- the filter to negate
Returns
- the negated filter
startsWith
staticstatic Filter startsWith(ODataProperty property, String prefix) startswith(property,'prefix').
Parameters
property- the string property to test
prefix- the text it must start with
Returns
- the filter
endsWith
staticstatic Filter endsWith(ODataProperty property, String suffix) endswith(property,'suffix').
Parameters
property- the string property to test
suffix- the text it must end with
Returns
- the filter
contains
staticstatic Filter contains(ODataProperty property, String text) contains(property,'text').
Parameters
property- the string property to test
text- the text it must contain
Returns
- the filter
any
staticstatic Filter any(String collectionPath, String variable, Function<Filter.Variable,Filter> condition) collection/any(v:condition): true if any member of a collection matches.
The lambda receives the range variable, from which to build paths
(v.nav("Name")).
Parameters
collectionPath- the path to the collection, e.g.
Hierarchies, used as is variable- the range variable's name, an OData identifier
condition- builds the condition from the range variable
Returns
- the filter
all
staticstatic Filter all(String collectionPath, String variable, Function<Filter.Variable,Filter> condition) collection/all(v:condition): true if every member of a collection matches.
Parameters
collectionPath- the path to the collection, e.g.
Hierarchies, used as is variable- the range variable's name, an OData identifier
condition- builds the condition from the range variable
Returns
- the filter
in
staticstatic Filter in(ODataProperty property, Object... values) property in (a,b,c). Not every TM1 version supports in; or
of eqs always works.
Parameters
property- the property to test
values- the values, at least one, written as OData literals
(
ODataLiterals.of)
Returns
- the filter
toString
String toString()The expression, unencoded, e.g. (Name eq 'Sales').
equals
boolean equals(Object o)hashCode
int hashCode()Also in the Javadoc.