Class JavaCodeSerializer

java.lang.Object
org.reflections.serializers.JavaCodeSerializer
All Implemented Interfaces:
Serializer

public class JavaCodeSerializer extends Object implements Serializer
source code serialization for Reflections
reflections.save(file, new JavaCodeSerializer())

an example of produced java source:
 public interface MyTestModelStore {
   interface org {
     interface reflections {
       interface TestModel$C4 {
         interface fields {
           interface f1 {}
           interface f2 {}
         }
         interface methods {
           interface m1 {}
           interface add {}
         }
         interface annotations {
           ...
         }
       }
     }
   }
 }
 

this allows strongly typed access by fqn to type elements - packages, classes, annotations, fields and methods:

MyTestModelStore.org.reflections.TestModel$C1.methods.m1.class

depends on TypeElementsScanner configured

  • Constructor Details

    • JavaCodeSerializer

      public JavaCodeSerializer()
  • Method Details

    • read

      public Reflections read(InputStream inputStream)
      Description copied from interface: Serializer
      reads the input stream into a new Reflections instance, populating it's store
      Specified by:
      read in interface Serializer
    • save

      public File save(Reflections reflections, String name)
      serialize and save to java source code
      Specified by:
      save in interface Serializer
      Parameters:
      name - should be in the pattern path/path/path/package.package.classname,
    • indentOpen

      protected int indentOpen(List<String> typePaths, List<String> prevPaths)
    • indentClose

      protected void indentClose(List<String> prevPaths)
    • addPackages

      protected void addPackages(List<String> typePaths, int i)
    • addClass

      protected void addClass(List<String> typePaths, String className)
    • addFields

      protected void addFields(List<String> typePaths, List<String> fields)
    • addMethods

      protected void addMethods(List<String> typePaths, List<String> fields, List<String> methods)
    • addAnnotations

      protected void addAnnotations(List<String> typePaths, List<String> annotations)