skipcheck

TM1 client · Docs · Queries

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 staticAn expression written by hand, used as is.
and staticAll of the given filters.
or staticAny of the given filters.
not staticnot filter.
startsWith staticstartswith(property,'prefix').
endsWith staticendswith(property,'suffix').
contains staticcontains(property,'text').
any staticTrue if any member of a collection matches.
all staticTrue if every member of a collection matches.
in staticproperty in (a,b,c).
toStringThe expression, unencoded, e.g.
equals
hashCode

raw

static
static Filter raw(String expression)

An expression written by hand, used as is. Combined with others by and or or, it's put in parentheses, so it keeps its meaning whatever operators it uses.

Parameters

expression
the expression, unencoded

Returns

the filter

and

static
static 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

static
static 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

static
static Filter not(Filter filter)

not filter.

Parameters

filter
the filter to negate

Returns

the negated filter

startsWith

static
static 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

static
static 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

static
static 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

static
static 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

static
static 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

static
static 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.