Class TemplatedResourceName

  • All Implemented Interfaces:
    Map<String,​String>

    public class TemplatedResourceName
    extends Object
    implements Map<String,​String>
    Class for representing and working with resource names.

    A resource name is represented by PathTemplate, an assignment to variables in the template, and an optional endpoint. The ResourceName class implements the map interface (unmodifiable) to work with the variable assignments, and has methods to reproduce the string representation of the name, to construct new names, and to dereference names into resources.

    As a resource name essentially represents a match of a path template against a string, it can be also used for other purposes than naming resources. However, not all provided methods may make sense in all applications.

    Usage examples:

    
     PathTemplate template = PathTemplate.create("shelves/*&#47;books/*");
     TemplatedResourceName resourceName = TemplatedResourceName.create(template, "shelves/s1/books/b1");
     assert resourceName.get("$1").equals("b1");
     assert resourceName.parentName().toString().equals("shelves/s1/books");