Class ReadableResourceProviderChain

java.lang.Object
com.helger.io.resourceprovider.ReadableResourceProviderChain
All Implemented Interfaces:
IReadableResourceProvider
Direct Known Subclasses:
WritableResourceProviderChain

@Immutable public class ReadableResourceProviderChain extends Object implements IReadableResourceProvider
A readable resource provider that chains multiple IReadableResourceProvider.
Author:
Philip Helger
  • Constructor Details

    • ReadableResourceProviderChain

      public ReadableResourceProviderChain(@NonNull IReadableResourceProvider... aResProviders)
      Constructor with a varargs array of resource providers.
      Parameters:
      aResProviders - The resource providers to use. May neither be null nor empty and may not contain null elements.
    • ReadableResourceProviderChain

      public ReadableResourceProviderChain(@NonNull Iterable<? extends IReadableResourceProvider> aResProviders)
      Constructor with an iterable of resource providers.
      Parameters:
      aResProviders - The resource providers to use. May neither be null nor empty and may not contain null elements.
  • Method Details

    • readingResourceProviders

      @ReturnsMutableObject protected final @NonNull com.helger.collection.commons.ICommonsList<IReadableResourceProvider> readingResourceProviders()
    • getAllContainedReadingResourceProviders

      @ReturnsMutableCopy public final @NonNull com.helger.collection.commons.ICommonsList<IReadableResourceProvider> getAllContainedReadingResourceProviders()
      Returns:
      A copy of all contained reading resource providers. Never null.
    • supportsReading

      public final boolean supportsReading(@Nullable String sName)
      Check if this resource provider can handle the resource with the passed name. If there is no real check on whether your resource provider can handle it, simply return true.
      Specified by:
      supportsReading in interface IReadableResourceProvider
      Parameters:
      sName - The name to check. May be null.
      Returns:
      true if the name is not null and can be handled by this provider, false otherwise.
    • getReadableResource

      @OverrideOnDemand public @NonNull IReadableResource getReadableResource(@NonNull String sName)
      Get the resource specified by the given name for reading.
      Specified by:
      getReadableResource in interface IReadableResourceProvider
      Parameters:
      sName - The name of the resource to resolve.
      Returns:
      The readable resource. Never null.
    • getReadableResourceIf

      public @Nullable IReadableResource getReadableResourceIf(@NonNull String sName, @NonNull Predicate<? super IReadableResource> aReturnFilter)
      Get a readable resource matching the name and filter.
      Parameters:
      sName - The name of the resource to resolve. May not be null.
      aReturnFilter - The filter to apply on found resources. May not be null.
      Returns:
      null if no matching resource was found.
    • getInputStream

      public @Nullable InputStream getInputStream(@NonNull String sName)
      Description copied from interface: IReadableResourceProvider
      Get the InputStream specified by the given name for reading. This method may be called without prior call to IReadableResourceProvider.supportsReading(String).
      Specified by:
      getInputStream in interface IReadableResourceProvider
      Parameters:
      sName - The name of the resource to resolve.
      Returns:
      The InputStream. May be null if the underlying resource does not exist or if IReadableResourceProvider.supportsReading(String) returns false.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object