Send feedback
Class TemplatedResourceName (2.33.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version 2.33.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.
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.
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.
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.
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
Name
Description
resourceType
Class <T >
version
String
Returns
Type
Description
T
clear() (deprecated)
containsKey(Object key)
public boolean containsKey ( Object key )
Parameter
Name
Description
key
Object
containsValue(Object value)
public boolean containsValue ( Object value )
Parameter
Name
Description
value
Object
endpoint()
Returns the endpoint of this resource name, or null if none is defined.
Returns
Type
Description
String
entrySet()
public Set<Map . Entry<String , String >> entrySet ()
equals(Object obj)
public boolean equals ( Object obj )
Parameter
Name
Description
obj
Object
Overrides
get(Object key)
public String get ( Object key )
Parameter
Name
Description
key
Object
Returns
Type
Description
String
hasEndpoint()
public boolean hasEndpoint ()
Checks whether the resource name has an endpoint.
hashCode()
Returns
Type
Description
int
Overrides
isEmpty()
keySet()
public Set<String> keySet ()
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
.
put(String key, String value) (deprecated)
public String put ( String key , String value )
Returns
Type
Description
String
putAll(Map<? extends String,? extends String> m) (deprecated)
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) (deprecated)
public String remove ( Object key )
Parameter
Name
Description
key
Object
Returns
Type
Description
String
size()
Returns
Type
Description
int
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.
template()
public PathTemplate template ()
Gets the template associated with this resource name.
toString()
Returns
Type
Description
String
Overrides
values()
public Collection<String> values ()
withEndpoint(String endpoint)
public TemplatedResourceName withEndpoint ( String endpoint )
Returns a resource name with specified endpoint.
Parameter
Name
Description
endpoint
String
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-12-12 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-12-12 UTC."],[],[]]