Package org.reflections.serializers
Class JavaCodeSerializer
java.lang.Object
org.reflections.serializers.JavaCodeSerializer
- All Implemented Interfaces:
Serializer
Serialization of Reflections to java code
Serializes types and types elements into interfaces respectively to fully qualified name,
For example, after saving with JavaCodeSerializer:
reflections.save(filename, new JavaCodeSerializer());
Saved file should look like:
public interface MyModel {
public interface my {
public interface package1 {
public interface MyClass1 {
public interface fields {
public interface f1 {}
public interface f2 {}
}
public interface methods {
public interface m1 {}
public interface m2 {}
}
...
}
Use the different resolve methods to resolve the serialized element into Class, Field or Method. for example:
Class m1Ref = MyModel.my.package1.MyClass1.methods.m1.class; Method method = JavaCodeSerializer.resolve(m1Ref);
The save(org.reflections.Reflections, String) method filename should be in the pattern: path/path/path/package.package.classname
depends on Reflections configured with TypeElementsScanner
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringgetNonDuplicateName(String candidate, List<String> prev) private StringgetNonDuplicateName(String candidate, List<String> prev, int offset) private Stringread(InputStream inputStream) reads the input stream into a new Reflections instance, populating it's storestatic AnnotationresolveAnnotation(Class annotation) static Class<?> resolveClass(Class aClass) static Class<?> resolveClassOf(Class element) static FieldresolveField(Class aField) static MethodresolveMethod(Class aMethod) save(Reflections reflections, String name) name should be in the pattern: path/path/path/package.package.classname, for exampletoString(Reflections reflections) returns a string serialization of the given Reflections instance
-
Field Details
-
pathSeparator
- See Also:
-
doubleSeparator
- See Also:
-
dotSeparator
- See Also:
-
arrayDescriptor
- See Also:
-
tokenSeparator
- See Also:
-
-
Constructor Details
-
JavaCodeSerializer
public JavaCodeSerializer()
-
-
Method Details
-
read
Description copied from interface:Serializerreads the input stream into a new Reflections instance, populating it's store- Specified by:
readin interfaceSerializer
-
save
name should be in the pattern: path/path/path/package.package.classname, for example/data/projects/my/src/main/java/org.my.project.MyStore
would create class MyStore in package org.my.project in the path /data/projects/my/src/main/java- Specified by:
savein interfaceSerializer
-
toString
Description copied from interface:Serializerreturns a string serialization of the given Reflections instance- Specified by:
toStringin interfaceSerializer
-
getNonDuplicateName
-
normalize
-
getNonDuplicateName
-
resolveClassOf
- Throws:
ClassNotFoundException
-
resolveClass
-
resolveField
-
resolveAnnotation
-
resolveMethod
-