public final class ResourceProvider extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Set<java.lang.ClassLoader> |
classLoaders
set of class loaders to take resources from
|
Modifier | Constructor and Description |
---|---|
private |
ResourceProvider() |
Modifier and Type | Method and Description |
---|---|
static boolean |
addAdditionalClassLoader(java.lang.ClassLoader additionalClassLoader)
Add an additional class loader to search image for.
|
static boolean |
addAdditionalClassLoaders(java.util.Collection<java.lang.ClassLoader> additionalClassLoaders)
Add a collection of additional class loaders to search image for.
|
private static <T> T |
getFirstNotNull(java.util.function.Function<java.lang.ClassLoader,T> function) |
static java.net.URL |
getResource(java.lang.String name)
Finds the resource with the given name.
|
static java.io.InputStream |
getResourceAsStream(java.lang.String name)
Finds a resource with a given name, with robustness to known JDK bugs.
|
private static final java.util.Set<java.lang.ClassLoader> classLoaders
private ResourceProvider()
public static boolean addAdditionalClassLoader(java.lang.ClassLoader additionalClassLoader)
additionalClassLoader
- class loader to add to the internal settrue
if the set changed as a result of the callpublic static boolean addAdditionalClassLoaders(java.util.Collection<java.lang.ClassLoader> additionalClassLoaders)
additionalClassLoaders
- class loaders to add to the internal settrue
if the set changed as a result of the callprivate static <T> T getFirstNotNull(java.util.function.Function<java.lang.ClassLoader,T> function)
public static java.net.URL getResource(java.lang.String name)
name
- The resource nameURL
object for reading the resource, or null
if the resource could not be found
or the invoker doesn't have adequate privileges to get the resource.ClassLoader.getResource(java.lang.String)
public static java.io.InputStream getResourceAsStream(java.lang.String name)
name
- name of the desired resourceInputStream
object or null
if no resource with this name is found