Class PackageScanner<T>
java.lang.Object
com.burchard36.api.utils.reflections.PackageScanner<T>
A generic package scanner, that will scan a specific
Package for a Class that
extends another Class. Not really intended for users of this API to use, but feel free to.- Since:
- 2.1.8
- Author:
- Dalton Burchard
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classReturned as an Entry value when usinginvokeClass(java.lang.Class<? extends T>)static classstatic classThe exception thrown when there is any generic error with this class. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWhilenot recommended n creating another instance of this class, you still can
You can get a running instance of this class after the API gets enabled, seeBurchAPI.getPackageScanner() -
Method Summary
Modifier and TypeMethodDescriptionexecute()Executes the query you set.HashMap<Class<? extends Annotation>,Class<? extends T>>findWithClassConstructorAnnotations(Class<? extends Annotation>... annotations)getClassesExtendingThis(Package thePackage, Class<? extends T> that)protected voidgetClassesForPackage(String pkgName)invokeClass(Class<? extends T> clazz)subclassSearchQuery(Package aPackage, Class<? extends T> aClass)Sets the package to scan, and type to scan for.updateTargetClass(Class<? extends T> clazz)Use this when you are still using the same package previous set by usingsubclassSearchQuery(java.lang.Package, java.lang.Class<? extends T>)
If you want to use a different Package, then usesubclassSearchQuery(java.lang.Package, java.lang.Class<? extends T>)
-
Field Details
-
packageToSearch
-
currentClassToSearch
-
classesForPackage
-
result
-
-
Constructor Details
-
PackageScanner
public PackageScanner()Whilenot recommended n creating another instance of this class, you still can
You can get a running instance of this class after the API gets enabled, seeBurchAPI.getPackageScanner()
-
-
Method Details
-
updateTargetClass
Use this when you are still using the same package previous set by usingsubclassSearchQuery(java.lang.Package, java.lang.Class<? extends T>)
If you want to use a different Package, then usesubclassSearchQuery(java.lang.Package, java.lang.Class<? extends T>)- Parameters:
clazz- Target class you want to check, typically a YourClass.class argument.- Returns:
- instance of this class
- Since:
- 2.1.8
-
invokeClass
public final PackageScanner.InvocationResult<T,PackageScanner.InvocationErrorStatus> invokeClass(Class<? extends T> clazz) -
findWithClassConstructorAnnotations
@SafeVarargs public final HashMap<Class<? extends Annotation>,Class<? extends T>> findWithClassConstructorAnnotations(Class<? extends Annotation>... annotations) -
subclassSearchQuery
public final PackageScanner<T> subclassSearchQuery(@Nonnull Package aPackage, @Nonnull Class<? extends T> aClass)Sets the package to scan, and type to scan for.
This will also cache all the classes for the specific package.- Parameters:
aPackage- APackagethe root package to start scanning ataClass- The class you want the return value of this- Returns:
- Instance of this class
- Since:
- 2.1.8
-
execute
Executes the query you set. Make sure you callsubclassSearchQuery(java.lang.Package, java.lang.Class<? extends T>)first or this will generatePackageScanner.PackageScannerException- Returns:
ListofClass's that extend a class you specified insubclassSearchQuery(java.lang.Package, java.lang.Class<? extends T>)- Since:
- 2.1.8
-
getClassesExtendingThis
protected final List<Class<? extends T>> getClassesExtendingThis(Package thePackage, Class<? extends T> that) throws IOException, ClassNotFoundException, URISyntaxException -
getClassesForPackage
- Throws:
IOExceptionURISyntaxException
-