@HashCodeAndEqualsPlugin.Enhance public static class MultipleParentClassLoader.Builder extends java.lang.Object
MultipleParentClassLoader
only if multiple or no
ClassLoader
s are found in the process. If exactly a single class loader is found,
this class loader is returned. All class loaders are applied in their collection order with the exception
of the bootstrap class loader which is represented by null
and which is an implicit parent of any
class loader.Modifier and Type | Field and Description |
---|---|
private java.util.List<? extends java.lang.ClassLoader> |
classLoaders
The class loaders that were collected.
|
private static int |
ONLY
Indicates the first index of a list.
|
private boolean |
sealed
true if the created class loader is sealed. |
Modifier | Constructor and Description |
---|---|
|
Builder()
Creates a new builder without any class loaders.
|
|
Builder(boolean sealed)
Creates a new builder without any class loaders.
|
private |
Builder(java.util.List<? extends java.lang.ClassLoader> classLoaders,
boolean sealed)
Creates a new builder.
|
Modifier and Type | Method and Description |
---|---|
MultipleParentClassLoader.Builder |
append(java.lang.Class<?>... type)
Appends the class loaders of the given types.
|
MultipleParentClassLoader.Builder |
append(java.lang.ClassLoader... classLoader)
Appends the given class loaders if they were not yet collected.
|
MultipleParentClassLoader.Builder |
append(java.util.Collection<? extends java.lang.Class<?>> types)
Appends the class loaders of the given types if those class loaders were not yet collected.
|
MultipleParentClassLoader.Builder |
append(java.util.List<? extends java.lang.ClassLoader> classLoaders)
Appends the given class loaders if they were not yet appended.
|
MultipleParentClassLoader.Builder |
appendMostSpecific(java.lang.Class<?>... type)
Appends the class loaders of the given types but filters any duplicates within the hierarchy of class loaders.
|
MultipleParentClassLoader.Builder |
appendMostSpecific(java.lang.ClassLoader... classLoader)
Appends the given class loaders but removes any class loaders that are the parent of any previously registered class loader.
|
MultipleParentClassLoader.Builder |
appendMostSpecific(java.util.Collection<? extends java.lang.Class<?>> types)
Appends the class loaders of the given types but filters any duplicates within the hierarchy of class loaders.
|
MultipleParentClassLoader.Builder |
appendMostSpecific(java.util.List<? extends java.lang.ClassLoader> classLoaders)
Appends the given class loaders but removes any class loaders that are the parent of any previously registered class loader.
|
java.lang.ClassLoader |
build()
Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as
a parent of all supplied class loader and with the bootstrap class loader as an implicit parent.
|
java.lang.ClassLoader |
build(java.lang.ClassLoader parent)
Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as
a parent of all supplied class loader and with the bootstrap class loader as an implicit parent.
|
private java.lang.ClassLoader |
doBuild(java.lang.ClassLoader parent)
Creates a multiple parent class loader with an explicit parent.
|
MultipleParentClassLoader.Builder |
filter(ElementMatcher<? super java.lang.ClassLoader> matcher)
Only retains all class loaders that match the given matcher.
|
private static final int ONLY
private final boolean sealed
true
if the created class loader is sealed.private final java.util.List<? extends java.lang.ClassLoader> classLoaders
public Builder()
public Builder(boolean sealed)
sealed
- true
if the created class loader is sealed.private Builder(java.util.List<? extends java.lang.ClassLoader> classLoaders, boolean sealed)
classLoaders
- The class loaders that were collected until now.sealed
- true
if the created class loader is sealed.public MultipleParentClassLoader.Builder append(java.lang.Class<?>... type)
type
- The types of which to collect the class loaders.public MultipleParentClassLoader.Builder append(java.util.Collection<? extends java.lang.Class<?>> types)
types
- The types of which to collect the class loaders.public MultipleParentClassLoader.Builder append(java.lang.ClassLoader... classLoader)
classLoader
- The class loaders to be collected.public MultipleParentClassLoader.Builder append(java.util.List<? extends java.lang.ClassLoader> classLoaders)
classLoaders
- The class loaders to collected.public MultipleParentClassLoader.Builder appendMostSpecific(java.lang.Class<?>... type)
type
- The types of which to collect the class loaders.public MultipleParentClassLoader.Builder appendMostSpecific(java.util.Collection<? extends java.lang.Class<?>> types)
types
- The types of which to collect the class loaders.public MultipleParentClassLoader.Builder appendMostSpecific(java.lang.ClassLoader... classLoader)
classLoader
- The class loaders to be collected.public MultipleParentClassLoader.Builder appendMostSpecific(java.util.List<? extends java.lang.ClassLoader> classLoaders)
classLoaders
- The class loaders to collected.public MultipleParentClassLoader.Builder filter(ElementMatcher<? super java.lang.ClassLoader> matcher)
matcher
- The matcher to be used for filtering.public java.lang.ClassLoader build()
Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as a parent of all supplied class loader and with the bootstrap class loader as an implicit parent. If no class loader was appended, a new class loader is created that declares no parents. If a class loader is created, its explicit parent is set to be the bootstrap class loader.
Important: Byte Buddy does not provide any access control for the creation of the class loader. It is the responsibility of the user of this builder to provide such privileges.
public java.lang.ClassLoader build(java.lang.ClassLoader parent)
Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as a parent of all supplied class loader and with the bootstrap class loader as an implicit parent. If no class loader was appended, or if only the supplied parent to this method was included, this class loader is returned,
Important: Byte Buddy does not provide any access control for the creation of the class loader. It is the responsibility of the user of this builder to provide such privileges.
parent
- The class loader's contractual parent which is accessible via ClassLoader.getParent()
. If this class loader
is also included in the appended class loaders, it is notprivate java.lang.ClassLoader doBuild(java.lang.ClassLoader parent)
parent
- The explicit parent class loader.