public interface ClassLookup
Implementations of this interface should handle the logic for aliasing classes and provide a mechanism for looking up classes by either their canonical name or an associated alias.
| Modifier and Type | Method and Description |
|---|---|
void |
addAlias(Class<?>... classes)
Adds one or more classes to the class lookup.
|
void |
addAlias(Class<?> clazz,
String names)
Adds a class to the class lookup with one or more specified aliases.
|
Class<?> |
forName(CharSequence name)
Looks up and returns the Class object associated with the given class name.
|
String |
nameFor(Class<?> clazz)
Retrieves the alias for the given class.
|
default @NotNull ClassLookup |
wrap()
Creates a new ClassLookup instance that wraps this instance.
|
default @NotNull ClassLookup |
wrap(@NotNull ClassLoader classLoader)
Creates a new ClassLookup instance that wraps this instance and uses the provided
class loader to look up new classes.
|
@NotNull default @NotNull ClassLookup wrap()
@NotNull default @NotNull ClassLookup wrap(@NotNull @NotNull ClassLoader classLoader)
classLoader - The ClassLoader used to look up new classes.NullPointerException - if classLoader is null.Class<?> forName(CharSequence name) throws ClassNotFoundRuntimeException
name - The fully qualified name of the desired class.ClassNotFoundRuntimeException - If the class cannot be located.String nameFor(Class<?> clazz) throws IllegalArgumentException
clazz - The class to retrieve the alias for.IllegalArgumentException - If this method is used on a lambda function.void addAlias(Class<?>... classes)
classes - The classes to be added to the class lookup.void addAlias(Class<?> clazz, String names)
clazz - The class to be added to the class lookup.names - A single alias or a comma-separated string of aliases for the class.Copyright © 2023. All rights reserved.