Interface ResourceRequest<T extends Resource>

Type Parameters:
T - the requested type
All Superinterfaces:
Cloneable
All Known Implementing Classes:
DefaultResourceRequest

public interface ResourceRequest<T extends Resource> extends Cloneable

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 Type
    Method
    Description
    boolean
    Returns true if resources of the given type satisfy this request.
    boolean
    Returns true if this request explicitly targets the type argument.
    Returns the name that the requested resource should have.
    ResourceType<? extends T>
    Returns the requested type.
    Returns the intents to be used for selecting providers.
    using(Set<Intent> intents)
    Returns a new resource request that uses project providers with the given intents.
    using(Intent intent, Intent... intents)
    Returns a new resource request that uses a project's providers with the given intents.
    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

      ResourceType<? extends T> type()
      Returns the requested type.
      Returns:
      the resource 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

      Returns the name that the requested resource should have.
      Returns:
      the name if set
    • using

      Returns a new resource request that uses project providers with the given intents.
      Parameters:
      intents - the intents
      Returns:
      the resource request
    • using

      default ResourceRequest<T> using(Intent intent, Intent... intents)
      Returns a new resource request that uses a project's providers with the given intents.
      Parameters:
      intent - the intent
      intents - the intents
      Returns:
      the resource request
    • usingAll

      Returns a new resource request that uses all providers of projects.
      Returns:
      the resource request
    • uses

      Returns the intents to be used for selecting providers.
      Returns:
      the intents
    • accepts

      boolean accepts(ResourceType<?> type)

      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

      boolean isFor(ResourceType<?> type)

      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