Send feedback
Class TemplatedResourceName (2.4.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version 2.4.0 keyboard_arrow_down
public class TemplatedResourceName 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/*/books/*" );
TemplatedResourceName resourceName = TemplatedResourceName . create ( template , "shelves/s1/books/b1" );
assert resourceName . get ( "$1" ). equals ( "b1" );
assert resourceName . parentName (). toString (). equals ( "shelves/s1/books" );
Inheritance
Object >
TemplatedResourceName
Static Methods
create(PathTemplate template, String path)
public static TemplatedResourceName create ( PathTemplate template , String path )
Creates a new resource name based on given template and path. The path must match the template,
otherwise null is returned.
Parameters
Returns
create(PathTemplate template, Map<String,String> values)
public static TemplatedResourceName create ( PathTemplate template , Map<String , String > values )
Creates a new resource name from a template and a value assignment for variables.
Parameters
Returns
createFromFullName(PathTemplate template, String path)
public static TemplatedResourceName createFromFullName ( PathTemplate template , String path )
Creates a new resource name based on given template and path, where the path contains an
endpoint. If the path does not match, null is returned.
Parameters
Returns
registerResourceNameResolver(TemplatedResourceName.Resolver resolver)
public static void registerResourceNameResolver ( TemplatedResourceName . Resolver resolver )
Sets the resource name resolver which is used by the <xref uid="com.google.api.pathtemplate.TemplatedResourceName.
Parameter
Methods
<T>resolve(Class<T> resourceType, String version)
public T <T>resolve ( Class<T> resourceType , String version )
Attempts to resolve a resource name into a resource, by calling the associated API. The
resource name must have an endpoint. An optional version can be specified to determine in which
version of the API to call.
Parameters
Returns
clear()
containsKey(Object key)
public boolean containsKey ( Object key )
Parameter
Returns
containsValue(Object value)
public boolean containsValue ( Object value )
Parameter
Returns
endpoint()
Returns the endpoint of this resource name, or null if none is defined.
Returns
entrySet()
public Set<Map . Entry<String , String >> entrySet ()
Returns
equals(Object obj)
public boolean equals ( Object obj )
Parameter
Returns
Overrides
get(Object key)
public String get ( Object key )
Parameter
Returns
hasEndpoint()
public boolean hasEndpoint ()
Checks whether the resource name has an endpoint.
Returns
hashCode()
Returns
Overrides
isEmpty()
Returns
keySet()
public Set<String> keySet ()
Returns
parentName()
public TemplatedResourceName parentName ()
Returns the parent resource name. For example, if the name is shelves/s1/books/b1
, the
parent is shelves/s1/books
.
Returns
put(String key, String value)
public String put ( String key , String value )
Parameters
Returns
putAll(Map<? extends String,? extends String> m)
public void putAll ( Map <? extends String , ? extends String > m )
Parameter
Name Description m Map <? extends java.lang.String ,? extends java.lang.String >
remove(Object key)
public String remove ( Object key )
Parameter
Returns
size()
Returns
startsWith(TemplatedResourceName parentName)
public boolean startsWith ( TemplatedResourceName parentName )
Returns true of the resource name starts with the parent resource name, i.e. is a child of the
parent.
Parameter
Returns
template()
public PathTemplate template ()
Gets the template associated with this resource name.
Returns
toString()
Returns
Overrides
values()
public Collection<String> values ()
Returns
withEndpoint(String endpoint)
public TemplatedResourceName withEndpoint ( String endpoint )
Returns a resource name with specified endpoint.
Parameter
Returns
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-06 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-06 UTC."],[],[]]