public class JavaParser
extends java.lang.Object
implements java.io.Closeable
Constructor and Description |
---|
JavaParser()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.lang.Iterable<? extends javax.tools.JavaFileObject> |
generate(javax.tools.JavaFileObject... sources)
Parses
sources into CompilationUnitTree units. |
java.lang.Iterable<? extends javax.tools.JavaFileObject> |
generate(java.lang.String className,
java.lang.String code)
Parses
sources into CompilationUnitTree units. |
protected AggregatingTypeElementVisitorProcessor |
getAggregatingTypeElementVisitorProcessor()
The type element visitor processor to use.
|
protected java.util.List<javax.annotation.processing.Processor> |
getAnnotationProcessors()
The list of processors to use.
|
protected BeanDefinitionInjectProcessor |
getBeanDefinitionInjectProcessor()
The
BeanDefinitionInjectProcessor to use. |
protected TypeElementVisitorProcessor |
getTypeElementVisitorProcessor()
The type element visitor processor to use.
|
java.lang.Iterable<? extends javax.lang.model.element.Element> |
parse(javax.tools.JavaFileObject... sources)
Parses
sources into CompilationUnitTree units. |
java.lang.Iterable<? extends javax.lang.model.element.Element> |
parseLines(java.lang.String className,
java.lang.String... lines)
Parses
sources into compilation units. |
java.io.Reader |
readGenerated(java.lang.String filePath,
java.lang.String className,
java.lang.String code)
Reads the contents of a generated file as a reader.
|
public java.lang.Iterable<? extends javax.lang.model.element.Element> parseLines(java.lang.String className, java.lang.String... lines)
sources
into compilation units. This method
does not compile the sources.className
- The class namelines
- The lines to parsepublic java.lang.Iterable<? extends javax.lang.model.element.Element> parse(javax.tools.JavaFileObject... sources)
sources
into CompilationUnitTree
units. This method
does not compile the sources.sources
- The sourcespublic java.lang.Iterable<? extends javax.tools.JavaFileObject> generate(java.lang.String className, java.lang.String code)
sources
into CompilationUnitTree
units. This method
does not compile the sources.className
- The class namecode
- the raw code@Nullable public java.io.Reader readGenerated(@NonNull java.lang.String filePath, java.lang.String className, java.lang.String code) throws java.io.IOException
filePath
- The file pathclassName
- The class name that produces the filecode
- The code of the classjava.io.IOException
- when an error occurs reading the filepublic java.lang.Iterable<? extends javax.tools.JavaFileObject> generate(javax.tools.JavaFileObject... sources)
sources
into CompilationUnitTree
units. This method
does not compile the sources.sources
- The sources@NonNull protected java.util.List<javax.annotation.processing.Processor> getAnnotationProcessors()
@NonNull protected BeanDefinitionInjectProcessor getBeanDefinitionInjectProcessor()
BeanDefinitionInjectProcessor
to use.BeanDefinitionInjectProcessor
@NonNull protected TypeElementVisitorProcessor getTypeElementVisitorProcessor()
@NonNull protected AggregatingTypeElementVisitorProcessor getAggregatingTypeElementVisitorProcessor()
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable