public class ClassIndex extends Object
Use @IndexAnnotated
and @IndexSubclasses
annotations to force the classes to be indexed.
Keep in mind that the class is indexed only when it is compiled with classindex.jar file in classpath.
Also to preserve class-index data when creating shaded jar you should use the following Maven configuration:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.atteo.classindex.ClassIndexTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
<dependencies>
<groupId>org.atteo.classindex</groupId>
<artifactId>classindex-transformer</artifactId>
</dependencies>
</plugin>
</plugins>
</build>
Modifier and Type | Field and Description |
---|---|
static String |
ANNOTATED_INDEX_PREFIX |
static String |
JAVADOC_PREFIX |
static String |
PACKAGE_INDEX_NAME |
static String |
SUBCLASS_INDEX_PREFIX |
Modifier and Type | Method and Description |
---|---|
static Iterable<Class<?>> |
getAnnotated(Class<? extends Annotation> annotation)
Retrieves a list of classes annotated by given annotation.
|
static Iterable<Class<?>> |
getAnnotated(Class<? extends Annotation> annotation,
ClassLoader classLoader)
Retrieves a list of classes annotated by given annotation.
|
static String |
getClassSummary(Class<?> klass)
Returns the Javadoc summary for given class.
|
static String |
getClassSummary(Class<?> klass,
ClassLoader classLoader)
Returns the Javadoc summary for given class.
|
static Iterable<Class<?>> |
getPackageClasses(String packageName)
Retrieves a list of classes from given package.
|
static Iterable<Class<?>> |
getPackageClasses(String packageName,
ClassLoader classLoader)
Retrieves a list of classes from given package.
|
static <T> Iterable<Class<? extends T>> |
getSubclasses(Class<T> superClass)
Retrieves a list of subclasses of the given class.
|
static <T> Iterable<Class<? extends T>> |
getSubclasses(Class<T> superClass,
ClassLoader classLoader)
Retrieves a list of subclasses of the given class.
|
public static final String SUBCLASS_INDEX_PREFIX
public static final String ANNOTATED_INDEX_PREFIX
public static final String PACKAGE_INDEX_NAME
public static final String JAVADOC_PREFIX
public static <T> Iterable<Class<? extends T>> getSubclasses(Class<T> superClass)
The class must be annotated with IndexSubclasses
for it's subclasses to be indexed
at compile-time by ClassIndexProcessor
.
superClass
- class to find subclasses forpublic static <T> Iterable<Class<? extends T>> getSubclasses(Class<T> superClass, ClassLoader classLoader)
The class must be annotated with IndexSubclasses
for it's subclasses to be indexed
at compile-time by ClassIndexProcessor
.
superClass
- class to find subclasses forclassLoader
- classloader for loading classespublic static Iterable<Class<?>> getPackageClasses(String packageName)
The package must be annotated with IndexSubclasses
for the classes inside
to be indexed at compile-time by ClassIndexProcessor
.
packageName
- name of the package to search classes forpublic static Iterable<Class<?>> getPackageClasses(String packageName, ClassLoader classLoader)
The package must be annotated with IndexSubclasses
for the classes inside
to be indexed at compile-time by ClassIndexProcessor
.
packageName
- name of the package to search classes forclassLoader
- classloader for loading classespublic static Iterable<Class<?>> getAnnotated(Class<? extends Annotation> annotation)
The annotation must be annotated with IndexAnnotated
for annotated classes
to be indexed at compile-time by ClassIndexProcessor
.
annotation
- annotation to search class forpublic static Iterable<Class<?>> getAnnotated(Class<? extends Annotation> annotation, ClassLoader classLoader)
The annotation must be annotated with IndexAnnotated
for annotated classes
to be indexed at compile-time by ClassIndexProcessor
.
annotation
- annotation to search class forclassLoader
- classloader for loading classespublic static String getClassSummary(Class<?> klass)
Javadoc summary is the first sentence of a Javadoc.
You need to use IndexSubclasses
or IndexAnnotated
with IndexAnnotated.storeJavadoc()
set to true.
klass
- class to retrieve summary forpublic static String getClassSummary(Class<?> klass, ClassLoader classLoader)
Javadoc summary is the first sentence of a Javadoc.
You need to use IndexSubclasses
or IndexAnnotated
with IndexAnnotated.storeJavadoc()
set to true.
klass
- class to retrieve summary forclassLoader
- classloader for loading classesCopyright © 2014 Atteo. All rights reserved.