Class Bundle
- All Implemented Interfaces:
Serializable
,Iterable<BundleResource>
- Direct Known Subclasses:
ReadsBundle
Each resource in a Bundle
is represented by a BundleResource
, which in turn describes
a binding mechanism for that resource (such as an IOPath
in the case of a URI, Path or file
name; or an input or output stream), and a "content type" string that is unique within that
Bundle
. Any string can be used as a content type. Predefined content type strings are defined
in BundleResourceType
.
A Bundle
must have one resource that is designated as the "primary" resource, specified
by a content type string. A resource with "primary content type" is is guaranteed to be present in
the Bundle
.
Since each resource in a Bundle
has a content type that is unique within that Bundle
,
a Bundle can not be used to represent a list of similar items where each item is equivalent to
each other item (i.e., a list of shards, where each shard in the list is equivalent to each other
shard). Rather Bundle
s are used to represent related resources where each resource has a unique
character or role relative to the other resources (i.e., a "reads" resource and a corresponding "index"
resource).
Bundles that contain only serializable (IOPathResource
) resources may be serialized to, and
deserialized from JSON.
- See Also:
-
Constructor Summary
ConstructorDescriptionBundle
(String primaryContentType, Collection<BundleResource> resources) Create a new bundle from an existing resource collection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the BundleResource for the provided targetContentType string.getOrThrow
(String requiredContentType) Get the BundleResource for the provided targetContentType string, or throw if no such resource exists.Get the primary content type for this bundle.Get the primaryBundleResource
for this bundle.Get the collection of resources from thisBundle
.int
hashCode()
iterator()
Get an iterator of BundleResources for this bundle.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Bundle
Create a new bundle from an existing resource collection.- Parameters:
primaryContentType
- the content type of the primary resource in this bundle. may not be null. a resource with this content type must be included in resourcesresources
- resources to include in this bundle, may not be null or empty
-
-
Method Details
-
get
Get the BundleResource for the provided targetContentType string.- Parameters:
targetContentType
- the content type to be retrieved from the bundle- Returns:
- an Optional
that contains the targetContent type
-
getOrThrow
Get the BundleResource for the provided targetContentType string, or throw if no such resource exists.- Parameters:
requiredContentType
- the content type to be retrieved from the bundle- Returns:
- a BundleResource of type targetContentType
- Throws:
IllegalArgumentException
- if the targetContentType resource isn't present in the bundle
-
getPrimaryContentType
Get the primary content type for this bundle.- Returns:
- the primary content type for this bundle
-
getPrimaryResource
Get the primaryBundleResource
for this bundle.- Returns:
- the primary
BundleResource
for this bundle.
-
getResources
Get the collection of resources from thisBundle
. -
iterator
Get an iterator of BundleResources for this bundle.- Specified by:
iterator
in interfaceIterable<BundleResource>
- Returns:
- iterator of BundleResources for this bundle.
-
equals
-
hashCode
public int hashCode() -
toString
-