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.ballerinalang.siddhi.annotation.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 Iterable<String> |
getAnnotatedNames(Class<? extends Annotation> annotation)
Retrieves names of classes annotated by given annotation.
|
static Iterable<String> |
getAnnotatedNames(Class<? extends Annotation> annotation,
ClassLoader classLoader)
Retrieves names 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 Iterable<String> |
getPackageClassesNames(String packageName)
Retrieves names of classes from given package.
|
static Iterable<String> |
getPackageClassesNames(String packageName,
ClassLoader classLoader)
Retrieves names 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.
|
static <T> Iterable<String> |
getSubclassesNames(Class<T> superClass)
Retrieves names of subclasses of the given class.
|
static <T> Iterable<String> |
getSubclassesNames(Class<T> superClass,
ClassLoader classLoader)
Retrieves names 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
.
T
- super class typesuperClass
- 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
.
T
- super class typesuperClass
- class to find subclasses forclassLoader
- classloader for loading classespublic static <T> Iterable<String> getSubclassesNames(Class<T> superClass)
The class must be annotated with IndexSubclasses
for it's subclasses to be indexed
at compile-time by ClassIndexProcessor
.
T
- super class typesuperClass
- class to find subclasses forpublic static <T> Iterable<String> getSubclassesNames(Class<T> superClass, ClassLoader classLoader)
The class must be annotated with IndexSubclasses
for it's subclasses to be indexed
at compile-time by ClassIndexProcessor
.
T
- super class typesuperClass
- class to find subclasses forclassLoader
- classloader for loading index filepublic 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<String> getPackageClassesNames(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<String> getPackageClassesNames(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 index filepublic 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 Iterable<String> getAnnotatedNames(Class<? extends Annotation> annotation)
The annotation must be annotated with IndexAnnotated
for annotated classes
to be indexed at compile-time by
ClassIndexProcessor
.
Please note there is no verification if the class really exists. It can be missing when incremental
compilation is used. Use getAnnotated(Class)
if you need the verification.
annotation
- annotation to search class forpublic static Iterable<String> getAnnotatedNames(Class<? extends Annotation> annotation, ClassLoader classLoader)
The annotation must be annotated with IndexAnnotated
for annotated classes
to be indexed at compile-time by
ClassIndexProcessor
.
Please note there is no verification if the class really exists. It can be missing when incremental
compilation is used. Use getAnnotated(Class, ClassLoader)
if you need the verification.
annotation
- annotation to search class forclassLoader
- classloader for loading the index filepublic 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 © 2018 WSO2. All rights reserved.