Interface PackContents

  • All Superinterfaces:
    java.lang.AutoCloseable, Nameable

    public interface PackContents
    extends Nameable, java.lang.AutoCloseable
    Represents the container that stores resources for retrieval.
    • Method Detail

      • resource

        java.util.Optional<Resource> resource​(PackType type,
                                              ResourcePath path)
                                       throws java.io.IOException
        Gets a resource within a path per type.

        If a resource is returned, be aware that is requires closing when you have finished working with the resource.

        Parameters:
        type - The type
        path - The domain named path
        Returns:
        The resource
        Throws:
        java.io.IOException
      • requireResource

        Resource requireResource​(PackType type,
                                 ResourcePath path)
                          throws java.io.IOException
        Gets a resource within a path per type.

        Ensure that you close the resource once you have finished working with it!

        Parameters:
        type - The type
        path - The domain named path
        Returns:
        The resource
        Throws:
        java.io.IOException
      • paths

        java.util.Collection<ResourcePath> paths​(PackType type,
                                                 java.lang.String namespace,
                                                 java.lang.String prefix,
                                                 int depth,
                                                 java.util.function.Predicate<java.lang.String> filter)
        Finds all the ResourcePaths in this pack matching the prefix and filter, and within the given depth.
        Parameters:
        type - The type
        namespace - The namespace to search
        prefix - The prefix of the path
        depth - The depth to search
        filter - The filter every path must match
        Returns:
        A collection of matching paths
        See Also:
        PackType
      • exists

        boolean exists​(PackType type,
                       ResourcePath path)
        Tests if this pack contains an entry at the given ResourcePath.
        Parameters:
        type - The type
        path - The resource path
        Returns:
        True if it exists, false if it does not
        See Also:
        PackType
      • namespaces

        java.util.Set<java.lang.String> namespaces​(PackType type)
        Gets the namespaces per type.
        Parameters:
        type - The type
        Returns:
        The set of namespaces
      • close

        void close()
        Specified by:
        close in interface java.lang.AutoCloseable