Compare commits
3 Commits
1f3011bd8f
...
8e8f4c4149
Author | SHA1 | Date | |
---|---|---|---|
8e8f4c4149 | |||
109e94991e | |||
|
7f885db883 |
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -8,7 +8,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
pom.xml
8
pom.xml
@@ -35,6 +35,14 @@
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.10.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<issueManagement>
|
||||
<system>Issue Tracker</system>
|
||||
<url>https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/issues</url>
|
||||
|
@@ -0,0 +1,18 @@
|
||||
// Author: maple
|
||||
// date: 9/29/25
|
||||
|
||||
package dev.unlegitdqrk.unlegitlibrary.reflections;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
/**
|
||||
* Implements utility for handling the Generic type
|
||||
*/
|
||||
public abstract class GenericReflectClass<T> {
|
||||
protected final Class<T> persistentClass;
|
||||
public GenericReflectClass() {
|
||||
this.persistentClass = (Class<T>)
|
||||
((ParameterizedType)getClass().getGenericSuperclass())
|
||||
.getActualTypeArguments()[0];
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
// Author: maple
|
||||
// date: 9/29/25
|
||||
|
||||
package dev.unlegitdqrk.unlegitlibrary.reflections.annotation.processing;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.reflections.GenericReflectClass;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AnnotationProcessor<A extends Annotation> extends GenericReflectClass<A> {
|
||||
protected Set<Class<?>> projectClasses;
|
||||
|
||||
protected Set<Class<?>> annotatedTypes;
|
||||
|
||||
protected Set<Method> annotatedMethods;
|
||||
|
||||
protected Set<Field> annotatedFields;
|
||||
|
||||
protected Set<Constructor> annotatedConstructors;
|
||||
|
||||
private final Reflections reflections;
|
||||
|
||||
public AnnotationProcessor(String packageName) {
|
||||
super();
|
||||
|
||||
this.reflections = new Reflections(packageName);
|
||||
|
||||
// load local sets
|
||||
this.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* reload local sets
|
||||
*/
|
||||
public void reload() {
|
||||
this.projectClasses = this.reflections.getSubTypesOf(Object.class);
|
||||
|
||||
this.annotatedTypes = this.reflections.getTypesAnnotatedWith(this.persistentClass);
|
||||
this.annotatedMethods = this.reflections.getMethodsAnnotatedWith(this.persistentClass);
|
||||
this.annotatedFields = this.reflections.getFieldsAnnotatedWith(this.persistentClass);
|
||||
this.annotatedConstructors = this.reflections.getConstructorsAnnotatedWith(this.persistentClass);
|
||||
}
|
||||
|
||||
public void process() {
|
||||
for(Class<?> type : this.annotatedTypes)
|
||||
processType(type);
|
||||
|
||||
for(Method method : this.annotatedMethods)
|
||||
processMethod(method);
|
||||
|
||||
for(Field field : this.annotatedFields)
|
||||
processField(field);
|
||||
|
||||
for(Constructor constructor : this.annotatedConstructors)
|
||||
processConstructor(constructor);
|
||||
}
|
||||
|
||||
|
||||
protected abstract void processType(Class<?> type);
|
||||
protected abstract void processMethod(Method method);
|
||||
protected abstract void processField(Field field);
|
||||
protected abstract void processConstructor(Constructor constructor);
|
||||
}
|
Reference in New Issue
Block a user