public class Resources extends Object implements Serializable
Constructor and Description |
---|
Resources() |
Modifier and Type | Method and Description |
---|---|
Resource |
add(Resource resource)
Adds a resource to the resources.
|
void |
addAll(Collection<Resource> resources)
Adds all resources from the given Collection of resources to the existing collection.
|
boolean |
containsByHref(String href)
Whether there exists a resource with the given href
|
boolean |
containsId(String id)
Whether the map of resources already contains a resource with the given id.
|
static Resource |
findFirstResourceByMediaType(Collection<Resource> resources,
MediaType mediaType)
Gets the first resource (random order) with the give mediatype.
|
Resource |
findFirstResourceByMediaType(MediaType mediaType)
Gets the first resource (random order) with the give mediatype.
|
void |
fixResourceId(Resource resource)
Checks the id of the given resource and changes to a unique identifier if it isn't one already.
|
Collection<Resource> |
getAll() |
Collection<String> |
getAllHrefs()
All resource hrefs
|
Resource |
getByHref(String href)
Gets the resource with the given href.
|
Resource |
getById(String id)
Gets the resource with the given id.
|
Resource |
getByIdOrHref(String idOrHref)
First tries to find a resource with as id the given idOrHref, if that
fails it tries to find one with the idOrHref as href.
|
Map<String,Resource> |
getResourceMap()
The resources that make up this book.
|
List<Resource> |
getResourcesByMediaType(MediaType mediaType)
All resources that have the given MediaType.
|
List<Resource> |
getResourcesByMediaTypes(MediaType[] mediaTypes)
All Resources that match any of the given list of MediaTypes
|
boolean |
isEmpty() |
Resource |
remove(String href)
Remove the resource with the given href.
|
void |
set(Collection<Resource> resources)
Sets the collection of Resources to the given collection of resources
|
void |
set(Map<String,Resource> resources)
Sets the collection of Resources to the given collection of resources
|
int |
size()
The number of resources
|
public Resource add(Resource resource)
resource
- public void fixResourceId(Resource resource)
resource
- public boolean containsId(String id)
id
- public Resource getById(String id)
id
- public Resource remove(String href)
href
- public boolean isEmpty()
public int size()
public Map<String,Resource> getResourceMap()
public Collection<Resource> getAll()
public boolean containsByHref(String href)
href
- public void set(Collection<Resource> resources)
resources
- public void addAll(Collection<Resource> resources)
resources
- public void set(Map<String,Resource> resources)
resources
- A map with as keys the resources href and as values the Resourcespublic Resource getByIdOrHref(String idOrHref)
idOrHref
- public Resource getByHref(String href)
href
- public Resource findFirstResourceByMediaType(MediaType mediaType)
mediaType
- public static Resource findFirstResourceByMediaType(Collection<Resource> resources, MediaType mediaType)
mediaType
- public List<Resource> getResourcesByMediaType(MediaType mediaType)
mediaType
- public List<Resource> getResourcesByMediaTypes(MediaType[] mediaTypes)
mediaTypes
- public Collection<String> getAllHrefs()
Copyright © 2009–2013. All rights reserved.