Package com.comphenix.protocol.utility
Interface ClassSource
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents an abstract class loader that can only retrieve classes by their canonical name.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringAppend to canonical names together.static ClassSourceempty()static ClassSourceConstruct a class source from the default class loader.static ClassSourcefromClassLoader(ClassLoader loader) Construct a class source from the given class loader.static ClassSourceConstruct a class source from a mapping of canonical names and the corresponding classes.static ClassSourcefromPackage(String packageName) Construct a class source from the default class loader and package.Retrieve a class by its canonical namedefault ClassSourceretry(ClassSource other) Retrieve a class source that will retry failed lookups in the given source.default ClassSourceusingPackage(String packageName) Retrieve a class source that prepends a specific package name to every lookup.
-
Method Details
-
fromClassLoader
Construct a class source from the default class loader.- Returns:
- A class source.
-
fromPackage
Construct a class source from the default class loader and package.- Parameters:
packageName- - the package that is prepended to every lookup.- Returns:
- A package source.
-
fromClassLoader
Construct a class source from the given class loader.- Parameters:
loader- - the class loader.- Returns:
- The corresponding class source.
-
fromMap
Construct a class source from a mapping of canonical names and the corresponding classes. If the map is null, it will be interpreted as an empty map. If the map does not contain a Class with the specified name, or that string maps to NULL explicitly, an empty optional will be returned- Parameters:
map- - map of class names and classes.- Returns:
- The class source.
-
empty
- Returns:
- A ClassLoader which will never successfully load a class.
-
append
Append to canonical names together.- Parameters:
a- - the name to the left.b- - the name to the right.- Returns:
- The full canonical name, with a dot seperator.
-
retry
Retrieve a class source that will retry failed lookups in the given source.- Parameters:
other- - the other class source.- Returns:
- A new class source.
-
usingPackage
Retrieve a class source that prepends a specific package name to every lookup.- Parameters:
packageName- - the package name to prepend.- Returns:
- The class source.
-
loadClass
Retrieve a class by its canonical name- Parameters:
canonicalName- The class's canonical name, i.e. java.lang.Object- Returns:
- Optional that may contain a Class
-