public class Contexts extends Object
Constructor and Description |
---|
Contexts() |
Modifier and Type | Method and Description |
---|---|
<T extends Described> |
contains(String name,
T resource) |
<T extends Described> |
delete(T resource)
Deletes a resource.
|
<T extends Described> |
get(String name,
Class<T> resourceClass) |
ImmutableList<DescribedResource<? extends Described>> |
getAllDescribedResources(ResourceInfo info)
Get all resource instances as
DescribedResource , sorted by name. |
ExecutorService |
getExecutorService()
Get executor service to use.
|
<T extends Described> |
getOrPut(String name,
Class<T> resourceClass,
Supplier<T> creator)
Get a resource object or create new if not exists.
|
static String |
keepResourceNameFriendlyCharacters(String inputOrNull)
Keep a subset of URL friendly characters.
|
List<ResourceInfo> |
listClasses()
List all available resource classes in precedence ordering.
|
ImmutableList<String> |
listDescriptions(ResourceInfo info) |
ImmutableList<String> |
listNames(ResourceInfo info) |
<T extends Described> |
listResources(Class<T> resourceClass)
List resources for a resource class.
|
ImmutableList<? extends Described> |
listResources(ResourceInfo info)
List resources for a resource info (by its
ResourceInfo ). |
ImmutableList<String> |
listUrls(ResourceInfo info) |
String |
nameOf(Described resource) |
<T extends Described> |
put(String name,
T resource)
Puts resource.
|
<T extends Described> |
putUnique(String namePrefix,
T resource)
Put new resource using an indexed name if exists.
|
void |
setExecutorService(ExecutorService ex)
Set executor service to use.
|
<T extends Described> |
urlOf(T resource) |
public static String keepResourceNameFriendlyCharacters(String inputOrNull)
inputOrNull
- Input or null
public void setExecutorService(ExecutorService ex)
ex
- Executor service to usepublic ExecutorService getExecutorService()
public ImmutableList<DescribedResource<? extends Described>> getAllDescribedResources(ResourceInfo info)
DescribedResource
, sorted by name.public List<ResourceInfo> listClasses()
public <T extends Described> ImmutableList<T> listResources(Class<T> resourceClass)
public ImmutableList<? extends Described> listResources(ResourceInfo info)
ResourceInfo
).public ImmutableList<String> listNames(ResourceInfo info)
public ImmutableList<String> listDescriptions(ResourceInfo info)
public ImmutableList<String> listUrls(ResourceInfo info)
public <T extends Described> String put(String name, T resource)
public <T extends Described> String putUnique(String namePrefix, T resource)
public <T extends Described> boolean contains(String name, T resource)
public <T extends Described> T getOrPut(String name, Class<T> resourceClass, Supplier<T> creator)
public <T extends Described> T get(String name, Class<T> resourceClass)
public <T extends Described> void delete(T resource)
IllegalArgumentException
- if not exists.public <T extends Described> String urlOf(T resource)
IllegalArgumentException
- if not foundpublic String nameOf(Described resource)
IllegalArgumentException
- if not found