Class ODataPath

java.lang.Object
io.skipcheck.tm1.client.odata.ODataPath

public final class ODataPath extends Object
A resource path relative to the service root, built from segments and encoded as it's built:
ODataPath element = ODataPath.of("Dimensions")
	.key("Region")
	.nav("Hierarchies")
	.key("Region")
	.nav("Elements")
	.key("O'Neil");
// Dimensions('Region')/Hierarchies('Region')/Elements('O''Neil')
ODataPath reserve = ODataPath.of("Cubes").key("Sales").action("tm1.Reserve");
// Cubes('Sales')/tm1.Reserve

Names (entity sets, navigation properties, operations, type casts) must be OData identifiers, optionally qualified; they're checked, never encoded. Key values can be any text: they're written as string literals and percent-encoded. Paths are immutable.

  • Method Details

    • of

      public static ODataPath of(String name)
      A path starting at an entity set, singleton or operation import, e.g. Cubes.
      Parameters:
      name - the first segment's name, an OData identifier
      Returns:
      a one-segment path
      Throws:
      IllegalArgumentException - if name isn't an identifier
    • metadata

      public static ODataPath metadata()
      The service's metadata document, $metadata: its CSDL XML. A path of its own, since $metadata isn't an identifier of(String) accepts.
      Returns:
      the path
    • batch

      public static ODataPath batch()
      The service's batch endpoint, $batch: a path of its own, as for metadata().
      Returns:
      the path
    • key

      public ODataPath key(String value)
      Adds a single-part key with a string value: ('Sales').
      Parameters:
      value - the key value, any text; quoted and percent-encoded
      Returns:
      a new path with the key on its last segment
      Throws:
      IllegalStateException - if the last segment already has a key or is a $ segment
    • key

      public ODataPath key(Object value)
      Adds a single-part key with a non-string value, such as a number: (42).
      Parameters:
      value - the key value, written as an OData literal (ODataLiterals.of(Object)); text is treated as by key(String)
      Returns:
      a new path with the key on its last segment
    • key

      public ODataPath key(Map<String,?> parts)
      Adds a compound key, in the order given: (ParentName='Total',ComponentName='Q1').
      Parameters:
      parts - the key's property names (identifiers) and values, in order
      Returns:
      a new path with the key on its last segment
      Throws:
      IllegalArgumentException - if parts is empty
    • cast

      public ODataPath cast(String qualifiedType)
      Adds a type-cast segment, e.g. tm1.NativeView.
      Parameters:
      qualifiedType - the namespace-qualified type name
      Returns:
      a new path with the segment added
    • action

      public ODataPath action(String qualifiedName)
      Adds a bound action segment, e.g. tm1.Reserve. Actions are invoked with POST.
      Parameters:
      qualifiedName - the namespace-qualified action name
      Returns:
      a new path with the segment added
    • function

      public ODataPath function(String qualifiedName, Map<String,?> parameters)
      Adds a bound function call with literal parameters, e.g. tm1.GetPartition(Begin=0,End=99). Use parameter aliases (in ODataQuery) for complex or collection parameters.
      Parameters:
      qualifiedName - the namespace-qualified function name
      parameters - the parameter names and values, in order; each value is written as an OData literal, or as the alias's name if it's an ODataPath.Alias
      Returns:
      a new path with the segment added
    • link

      public static ODataPath link(String link)
      A path a server returned, such as a delta link (MessageLogEntries/!delta('…')), relative to the service root and not yet encoded: each segment is percent-encoded as it is (keeping !, (, ) and '), without checking it's an identifier.
      Parameters:
      link - the path, without a query
      Returns:
      the path
      Throws:
      IllegalArgumentException - if it's empty, absolute or has a query
    • functionImport

      public static ODataPath functionImport(String name, Map<String,?> parameters)
      A function import called from the service root, e.g. ModelCubes() or TailMessageLog(Top=10).
      Parameters:
      name - the import's name, unqualified
      parameters - the parameter names and values, in order, as for function(String, Map)
      Returns:
      the path
    • value

      public ODataPath value()
      Adds $value: a property's or media entity's raw value.
      Returns:
      a new path with the segment added
    • count

      public ODataPath count()
      Adds $count: the number of items in a collection, as plain text.
      Returns:
      a new path with the segment added
    • ref

      public ODataPath ref()
      Adds $ref: references to entities rather than the entities themselves.
      Returns:
      a new path with the segment added
    • toString

      public String toString()
      The encoded path, without a leading slash, e.g. Cubes('Sales')/Views.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object