Package org.eclipse.ditto.model.policies
Interface Resources
-
- All Superinterfaces:
Iterable<Resource>
,org.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
,org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelector
,org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelectorAndPredicate<org.eclipse.ditto.json.JsonField>
,org.eclipse.ditto.model.base.json.Jsonifiable.WithPointer<org.eclipse.ditto.json.JsonObject>
,org.eclipse.ditto.model.base.json.Jsonifiable.WithPredicate<org.eclipse.ditto.json.JsonObject,org.eclipse.ditto.json.JsonField>
public interface Resources extends Iterable<Resource>, org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelectorAndPredicate<org.eclipse.ditto.json.JsonField>
A collection ofResource
s contained in a singlePolicyEntry
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelector, org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelectorAndPredicate<T extends Object>, org.eclipse.ditto.model.base.json.Jsonifiable.WithPointer<J extends org.eclipse.ditto.json.JsonValue>, org.eclipse.ditto.model.base.json.Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T extends Object>
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Optional<Resource>
getResource(String resourceType, CharSequence resourcePath)
Returns the Resource with the givenresourceType
andresourcePath
or an empty optional.Optional<Resource>
getResource(ResourceKey resourceKey)
Returns the Resource with the givenresourcePath
or an empty optional.int
getSize()
Returns the size of this Resources, i.default org.eclipse.ditto.model.base.json.JsonSchemaVersion[]
getSupportedSchemaVersions()
Returns the supported JSON schema version of this resources.boolean
isEmpty()
Indicates whether this Resources is empty.static Resources
newInstance(Iterable<Resource> resources)
Returns a newResources
containing the given resources.static Resources
newInstance(Resource resource, Resource... furtherResources)
Returns a newResources
containing the given resource.default Resources
removeResource(String resourceType, CharSequence resourcePath)
Removes the Resource with the givenresourceType
andresourcePath
from a copy of this Resources.Resources
removeResource(ResourceKey resourceKey)
Removes the Resource with the givenresourcePath
from a copy of this Resources.Resources
setResource(Resource resource)
Sets the given Resource to a copy of this Resources.Stream<Resource>
stream()
Returns a sequentialStream
with the values of this Resources as its source.default org.eclipse.ditto.json.JsonObject
toJson()
Returns all non hidden marked fields of this Resources.default org.eclipse.ditto.json.JsonObject
toJson(org.eclipse.ditto.model.base.json.JsonSchemaVersion schemaVersion, org.eclipse.ditto.json.JsonFieldSelector fieldSelector)
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
getImplementedSchemaVersion, getLatestSchemaVersion, implementsSchemaVersion, implementsSchemaVersion, toJsonString
-
Methods inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelector
toJson, toJson, toJson, toJsonString, toJsonString
-
Methods inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelectorAndPredicate
toJson, toJson, toJsonString, toJsonString
-
-
-
-
Method Detail
-
newInstance
static Resources newInstance(Iterable<Resource> resources)
Returns a newResources
containing the given resources.- Parameters:
resources
- theResource
s to be contained in the new Resources.- Returns:
- the new
Resources
. - Throws:
NullPointerException
- ifresources
isnull
.
-
newInstance
static Resources newInstance(Resource resource, Resource... furtherResources)
Returns a newResources
containing the given resource.- Parameters:
resource
- theResource
to be contained in the new Resources.furtherResources
- furtherResource
s to be contained in the new Resources.- Returns:
- the new
Resources
. - Throws:
NullPointerException
- if any argument isnull
.
-
getSupportedSchemaVersions
default org.eclipse.ditto.model.base.json.JsonSchemaVersion[] getSupportedSchemaVersions()
Returns the supported JSON schema version of this resources. Resources support onlyJsonSchemaVersion.V_2
.- Specified by:
getSupportedSchemaVersions
in interfaceorg.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
- Returns:
- the supported schema version.
-
getResource
default Optional<Resource> getResource(String resourceType, CharSequence resourcePath)
Returns the Resource with the givenresourceType
andresourcePath
or an empty optional.- Parameters:
resourceType
- the type of the Resource to be retrieved.resourcePath
- the path of the Resource to be retrieved.- Returns:
- the Resource or an empty optional.
- Throws:
NullPointerException
- ifresourcePath
isnull
.IllegalArgumentException
- ifresourceType
is empty.
-
getResource
Optional<Resource> getResource(ResourceKey resourceKey)
Returns the Resource with the givenresourcePath
or an empty optional.- Parameters:
resourceKey
- the ResourceKey of the Resource to be retrieved.- Returns:
- the Resource with the given path or an empty optional.
- Throws:
NullPointerException
- ifpath
isnull
.
-
setResource
Resources setResource(Resource resource)
Sets the given Resource to a copy of this Resources. A previous Resource with the same identifier will be overwritten.- Parameters:
resource
- the Resource to be set.- Returns:
- a copy of this Resources with
resource
set. - Throws:
NullPointerException
- ifresource
isnull
.
-
removeResource
default Resources removeResource(String resourceType, CharSequence resourcePath)
Removes the Resource with the givenresourceType
andresourcePath
from a copy of this Resources.- Parameters:
resourceType
- the type of the Resource to be removed.resourcePath
- the path of the Resource to be removed.- Returns:
- a copy of this Resources with
resource
removed. - Throws:
NullPointerException
- if any argument isnull
.IllegalArgumentException
- ifresourceType
is empty.
-
removeResource
Resources removeResource(ResourceKey resourceKey)
Removes the Resource with the givenresourcePath
from a copy of this Resources.- Parameters:
resourceKey
- the ResourceKey of the Resource to be removed.- Returns:
- a copy of this Resources with
resource
removed. - Throws:
NullPointerException
- ifresourceKey
isnull
.
-
getSize
int getSize()
Returns the size of this Resources, i. e. the number of contained values.- Returns:
- the size.
-
isEmpty
boolean isEmpty()
Indicates whether this Resources is empty.- Returns:
true
if this Resources does not contain any values,false
else.
-
stream
Stream<Resource> stream()
Returns a sequentialStream
with the values of this Resources as its source.- Returns:
- a sequential stream of the Resources of this container.
-
toJson
default org.eclipse.ditto.json.JsonObject toJson()
Returns all non hidden marked fields of this Resources.- Specified by:
toJson
in interfaceorg.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
- Returns:
- a JSON object representation of this Resources including only non hidden marked fields.
-
toJson
default org.eclipse.ditto.json.JsonObject toJson(org.eclipse.ditto.model.base.json.JsonSchemaVersion schemaVersion, org.eclipse.ditto.json.JsonFieldSelector fieldSelector)
- Specified by:
toJson
in interfaceorg.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelector
-
-