Class ResourceList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.AutoCloseable, java.lang.Cloneable, java.lang.Iterable<Resource>, java.util.Collection<Resource>, java.util.List<Resource>, java.util.RandomAccess

    public class ResourceList
    extends java.util.ArrayList<Resource>
    implements java.lang.AutoCloseable
    An AutoCloseable list of AutoCloseable Resource objects.
    See Also:
    Serialized Form
    • Method Detail

      • getPaths

        public java.util.List<java.lang.String> getPaths()
        Returns:
        The paths of all resources in this list relative to the package root of the classpath element, by calling Resource.getPath() for each item in the list. For example, given a resource path of "BOOT-INF/classes/com/xyz/resource.xml" and a package root of "BOOT-INF/classes/", returns "com/xyz/resource.xml".
      • getPathsRelativeToClasspathElement

        public java.util.List<java.lang.String> getPathsRelativeToClasspathElement()
        Returns:
        The paths of all resources in this list relative to the root of the classpath element, by calling Resource.getPathRelativeToClasspathElement() for each item in the list. For example, given a resource path of "BOOT-INF/classes/com/xyz/resource.xml", returns "BOOT-INF/classes/com/xyz/resource.xml" (even if the package root is "BOOT-INF/classes/").
      • getURLs

        public java.util.List<java.net.URL> getURLs()
        Returns:
        The URLs of all resources in this list, by calling Resource.getURL() for each item in the list.
      • classFilesOnly

        public ResourceList classFilesOnly()
        Returns:
        A new ResourceList consisting of only the resources with the filename extension ".class".
      • nonClassFilesOnly

        public ResourceList nonClassFilesOnly()
        Returns:
        A new ResourceList consisting of only the resources that do not have the filename extension ".class".
      • findDuplicatePaths

        public java.util.List<java.util.Map.Entry<java.lang.String,​ResourceList>> findDuplicatePaths()
        Returns:
        A List of Map.Entry objects for all resources in the classpath and/or module path that have a non-unique path (i.e. where there are at least two resources with the same path). The key of each returned Map.Entry is the path (obtained from Resource.getPath()), and the value is a ResourceList of at least two unique Resource objects that have that path.
      • forEachByteArray

        public void forEachByteArray​(ResourceList.ByteArrayConsumer byteArrayConsumer,
                                     boolean ignoreIOExceptions)
        Fetch the content of each Resource in this ResourceList as a byte array, pass the byte array to the given ResourceList.ByteArrayConsumer, then close the underlying InputStream or release the underlying ByteBuffer by calling Resource.close().
        Parameters:
        byteArrayConsumer - The ResourceList.ByteArrayConsumer.
        ignoreIOExceptions - if true, any IOException thrown while trying to load any of the resources will be silently ignored.
        Throws:
        java.lang.IllegalArgumentException - if ignoreExceptions is false, and an IOException is thrown while trying to load any of the resources.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<Resource>
      • close

        public void close()
        Close all the Resource objects in this ResourceList.
        Specified by:
        close in interface java.lang.AutoCloseable