T
- the resource type.public class CachedResources<T extends DataObjectRestRep>
extends java.lang.Object
Constructor and Description |
---|
CachedResources(Resources<T> resources) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the cached values.
|
T |
get(RelatedResourceRep ref)
Gets a list resource by reference, first checking if it is already in the cache.
|
T |
get(java.net.URI id)
Gets a resource by ID, first checking if it is already in the cache.
|
java.util.List<T> |
getByIds(java.util.Collection<java.net.URI> ids)
Gets a list of resources by IDs, checking the cache for each.
|
java.util.List<T> |
getByIds(java.util.Collection<java.net.URI> ids,
ResourceFilter<T> filter)
Gets a list of resources by IDs, checking the cache for each.
|
java.util.List<T> |
getByRefs(java.util.Collection<? extends RelatedResourceRep> refs)
Gets a list of resources by reference, checking the cache for each.
|
java.util.List<T> |
getByRefs(java.util.Collection<? extends RelatedResourceRep> refs,
ResourceFilter<T> filter)
Gets a list of resources by reference, checking the cache for each.
|
T |
getCached(java.net.URI id)
Gets the resource from the cache only.
|
boolean |
isCached(java.net.URI id)
Determines if the cache contains the given resource by ID
|
T |
remove(RelatedResourceRep ref)
Removes a resource from the cache.
|
T |
remove(java.net.URI id)
Removes a resource from the cache.
|
public T get(java.net.URI id)
id
- the resource ID.public T get(RelatedResourceRep ref)
ref
- the resource reference.public java.util.List<T> getByRefs(java.util.Collection<? extends RelatedResourceRep> refs)
getByRefs(refs, null)
.refs
- the resource references.getByRefs(Collection, ResourceFilter)
public java.util.List<T> getByRefs(java.util.Collection<? extends RelatedResourceRep> refs, ResourceFilter<T> filter)
refs
- the resource references.filter
- the filter to apply (may be null).public java.util.List<T> getByIds(java.util.Collection<java.net.URI> ids)
getByIds(ids, null)
.ids
- the resource IDs.getByIds(Collection, ResourceFilter)
public java.util.List<T> getByIds(java.util.Collection<java.net.URI> ids, ResourceFilter<T> filter)
ids
- the resource IDs.filter
- the filter to apply (may be null).public boolean isCached(java.net.URI id)
id
- resource ID.public T getCached(java.net.URI id)
id
- the resource ID.public void clear()
public T remove(java.net.URI id)
id
- the resource ID.public T remove(RelatedResourceRep ref)
ref
- the resource reference.