Class MatchingResources

    • Method Detail

      • getAllMatches

        public Resource[] getAllMatches()
        Get all matching resources
        Returns:
        A Resource array of all matches. If no matches are found this is a zero-length array.
      • getAllMatchesURL

        public URL[] getAllMatchesURL()
        Get all matching resources as URLs.
        Returns:
        URL array detemined by calling getURL(Resource) on each resource.
      • getAnnotatedMatches

        public List<Class<?>> getAnnotatedMatches​(Class<? extends Annotation> annotation,
                                                  boolean includeSubclasses)
        Get all matching classes that are annotated with the given Annotation.
        Parameters:
        annotation - an annotation class
        includeSubclasses - if true, this will also return classes whose superclass has the specified annotation
        Returns:
        List of all classes that have the given annotation. List is empty if non matches found.
      • getAnnotatedMatches

        public List<Class<?>> getAnnotatedMatches​(Class<? extends Annotation> annotation)
        Get all matching classes that are annotated with the given Annotation. Note that this method only returns those classes that actually contain the annotation, and does not return classes whose superclass contains the annotation.
        Parameters:
        annotation - an annotation class
        Returns:
        List of all classes that have the given annotation. List is empty if non matches found.
        See Also:
        getAnnotatedMatches(Class, boolean)
      • getSingleResource

        public Resource getSingleResource()
        Get a single matching resource. Throws an exception if multiple are found. This is useful if you are expecting to find only one instance of an item on the classpath.
        Returns:
        The single matching Resource
        Throws:
        RuntimeException - if more than one Resource was found
      • getSingleRequiredResource

        public Resource getSingleRequiredResource()
        Get a single required matching resource. Throws an exception if zero or multiple are found. This is useful if you are expecting to find one and only one instance of an item on the classpath.
        Returns:
        The single matching Resource
        Throws:
        RuntimeException - if zero or more than one Resource was found
      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        string representing all matching resouces as URLs