Interface ResourceRequest<T extends Resource>
- Type Parameters:
T- the requested type
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
DefaultResourceRequest
Represents a request for Resources of a specified type, to be
processed by a ResourceProvider.
When requesting resources from a Project, the Project forwards
the request to its dependencies that have been associated with one
of the Intents specified with using(Set).
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(ResourceType<?> type) Returns true if resources of the given type satisfy this request.booleanisFor(ResourceType<?> type) Returns true if this request explicitly targets the type argument.name()Returns the name that the requested resource should have.ResourceType<? extends T> type()Returns the requested type.uses()Returns the intents to be used for selecting providers.Returns a new resource request that uses project providers with the given intents.default ResourceRequest<T> Returns a new resource request that uses a project's providers with the given intents.default ResourceRequest<T> usingAll()Returns a new resource request that uses all providers of projects.Returns a new resource request for a resource with the given name.
-
Method Details
-
type
-
withName
Returns a new resource request for a resource with the given name.
Support for resource names is optional and provider-specific. Expect the name to be ignored if not explicitly supported for a given resource type and provider.
- Parameters:
name- the name- Returns:
- the resource request
-
name
-
using
Returns a new resource request that uses project providers with the given intents.- Parameters:
intents- the intents- Returns:
- the resource request
-
using
Returns a new resource request that uses a project's providers with the given intents.- Parameters:
intent- the intentintents- the intents- Returns:
- the resource request
-
usingAll
Returns a new resource request that uses all providers of projects.- Returns:
- the resource request
-
uses
-
accepts
Returns true if resources of the given type satisfy this request. This method is typically used by providers to decide whether to provide their resources of that type in response to the request.
Technically, this is the same as
type().isAssignableFrom(type).- Parameters:
type- the type to check- Returns:
- true if resources of the type would satisfy this request
-
isFor
Returns true if this request explicitly targets the type argument. This method is typically used by providers that can provide variants of a resource type to check which variant should be provided.
Technically, this is the same as
type.isAssignableFrom(type()).- Parameters:
type- the type to check- Returns:
- true, if successful
-