public class GroovyVisitorContext extends java.lang.Object implements VisitorContext
MICRONAUT_BASE_OPTION_NAME, MICRONAUT_PROCESSING_GROUP, MICRONAUT_PROCESSING_MODULE, MICRONAUT_PROCESSING_PROJECT_DIR
EMPTY
Constructor and Description |
---|
GroovyVisitorContext(org.codehaus.groovy.control.SourceUnit sourceUnit,
org.codehaus.groovy.control.CompilationUnit compilationUnit) |
Modifier and Type | Method and Description |
---|---|
MutableConvertibleValues<java.lang.Object> |
clear()
Clear all values.
|
void |
fail(java.lang.String message,
Element element)
Allows failing compilation for a given element with the given message.
|
void |
finish()
Finish writing and flush any service entries to disk.
|
<T> java.util.Optional<T> |
get(java.lang.CharSequence name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
java.util.Optional<ClassElement> |
getClassElement(java.lang.Class<?> type)
This method will lookup another class element by name.
|
java.util.Optional<ClassElement> |
getClassElement(java.lang.String name)
This method will lookup another class element by name.
|
ClassElement[] |
getClassElements(java.lang.String aPackage,
java.lang.String... stereotypes)
Find all the classes within the given package and having the given annotation.
|
java.lang.Iterable<java.net.URL> |
getClasspathResources(java.lang.String path)
Obtain a set of resources from the user classpath.
|
java.util.Map<java.lang.String,java.lang.String> |
getOptions()
Groovy options source are
System.getProperties() based. |
void |
info(java.lang.String message)
Allows printing informational messages.
|
void |
info(java.lang.String message,
Element element)
Allows printing informational messages.
|
java.util.Set<java.lang.String> |
names() |
MutableConvertibleValues<java.lang.Object> |
put(java.lang.CharSequence key,
java.lang.Object value)
Insert a value for the given key and value.
|
MutableConvertibleValues<java.lang.Object> |
remove(java.lang.CharSequence key)
Remove a value for the given key.
|
java.util.Collection<java.lang.Object> |
values() |
java.io.OutputStream |
visitClass(java.lang.String classname,
Element originatingElement)
Visits a new class and returns the output stream with which should be written the bytes of the class to be
generated.
|
java.util.Optional<GeneratedFile> |
visitGeneratedFile(java.lang.String path)
Visit a file that will be located within the generated source directory.
|
java.util.Optional<GeneratedFile> |
visitMetaInfFile(java.lang.String path)
Visit a file within the META-INF directory.
|
void |
visitServiceDescriptor(java.lang.String type,
java.lang.String classname)
Allows adding a class that will be written to the
META-INF/services file under the given type and class
name. |
void |
warn(java.lang.String message,
Element element)
Allows printing a warning for the given message and element.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProjectDir
of, putAll, putAll
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMap
get, get, get
getServiceEntries, visitClass, visitServiceDescriptor
public GroovyVisitorContext(org.codehaus.groovy.control.SourceUnit sourceUnit, @Nullable org.codehaus.groovy.control.CompilationUnit compilationUnit)
sourceUnit
- The source unitcompilationUnit
- The compilation unit@NonNull public java.lang.Iterable<java.net.URL> getClasspathResources(@NonNull java.lang.String path)
VisitorContext
getClasspathResources
in interface VisitorContext
path
- The pathpublic java.util.Optional<ClassElement> getClassElement(java.lang.String name)
VisitorContext
getClassElement
in interface VisitorContext
name
- The namepublic java.util.Optional<ClassElement> getClassElement(java.lang.Class<?> type)
VisitorContext
getClassElement
in interface VisitorContext
type
- The name@NonNull public ClassElement[] getClassElements(@NonNull java.lang.String aPackage, @NonNull java.lang.String... stereotypes)
VisitorContext
getClassElements
in interface VisitorContext
aPackage
- The packagestereotypes
- The stereotypespublic void info(java.lang.String message, @Nullable Element element)
VisitorContext
info
in interface VisitorContext
message
- The messageelement
- The elementpublic void info(java.lang.String message)
VisitorContext
info
in interface VisitorContext
message
- The messagepublic void fail(java.lang.String message, @Nullable Element element)
VisitorContext
fail
in interface VisitorContext
message
- The messageelement
- The elementpublic void warn(java.lang.String message, @Nullable Element element)
VisitorContext
warn
in interface VisitorContext
message
- The messageelement
- The elementpublic java.io.OutputStream visitClass(java.lang.String classname, @Nullable Element originatingElement) throws java.io.IOException
ClassWriterOutputVisitor
visitClass
in interface ClassWriterOutputVisitor
classname
- the fully qualified classnameoriginatingElement
- The originating elementjava.io.IOException
- if an error occurs creating the output streampublic void visitServiceDescriptor(java.lang.String type, java.lang.String classname)
ClassWriterOutputVisitor
META-INF/services
file under the given type and class
name.visitServiceDescriptor
in interface ClassWriterOutputVisitor
type
- the fully qualified service nameclassname
- the fully qualified classnamepublic java.util.Optional<GeneratedFile> visitMetaInfFile(java.lang.String path)
VisitorContext
visitMetaInfFile
in interface VisitorContext
visitMetaInfFile
in interface ClassWriterOutputVisitor
path
- The path to the filepublic java.util.Optional<GeneratedFile> visitGeneratedFile(java.lang.String path)
VisitorContext
visitGeneratedFile
in interface VisitorContext
visitGeneratedFile
in interface ClassWriterOutputVisitor
path
- The path to the filepublic void finish()
ClassWriterOutputVisitor
finish
in interface ClassWriterOutputVisitor
public java.util.Map<java.lang.String,java.lang.String> getOptions()
System.getProperties()
based.
All properties MUST start with VisitorContext.MICRONAUT_BASE_OPTION_NAME
getOptions
in interface VisitorContext
Map
ProcessingEnvironment.getOptions()
public MutableConvertibleValues<java.lang.Object> put(java.lang.CharSequence key, @Nullable java.lang.Object value)
MutableConvertibleValues
put
in interface MutableConvertibleValues<java.lang.Object>
key
- The keyvalue
- The valuepublic MutableConvertibleValues<java.lang.Object> remove(java.lang.CharSequence key)
MutableConvertibleValues
remove
in interface MutableConvertibleValues<java.lang.Object>
key
- The keypublic MutableConvertibleValues<java.lang.Object> clear()
MutableConvertibleValues
clear
in interface MutableConvertibleValues<java.lang.Object>
public java.util.Set<java.lang.String> names()
names
in interface ConvertibleValues<java.lang.Object>
public java.util.Collection<java.lang.Object> values()
values
in interface ConvertibleValues<java.lang.Object>
public <T> java.util.Optional<T> get(java.lang.CharSequence name, ArgumentConversionContext<T> conversionContext)
ValueResolver
get
in interface ValueResolver<java.lang.CharSequence>
T
- The concrete typename
- The nameconversionContext
- The conversion context