public abstract class DelegatingSourceGenerationContext extends java.lang.Object implements AOTContext
Constructor and Description |
---|
DelegatingSourceGenerationContext(AOTContext delegate) |
Modifier and Type | Method and Description |
---|---|
void |
addDiagnostics(java.lang.String category,
java.lang.String message)
Adds a diagnostic message, which is going to be written
in a log file.
|
<T> java.util.Optional<T> |
get(java.lang.Class<T> type)
Reads an entry from the context.
|
ApplicationContextAnalyzer |
getAnalyzer()
Returns the application context analyzer.
|
Configuration |
getConfiguration()
Returns the source generators configuration.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getDiagnostics()
Returns the diagnostics map.
|
java.lang.String |
getPackageName()
The package which should be used for generated classes.
|
Runtime |
getRuntime()
Returns the target runtime environment.
|
com.squareup.javapoet.JavaFile |
javaFile(com.squareup.javapoet.TypeSpec typeSpec)
Generates a java file spec.
|
<T> void |
put(java.lang.Class<T> type,
T value)
Stores an entry in the context.
|
void |
registerClassNeededAtCompileTime(java.lang.Class<?> clazz)
Registers a class as needed at compile time (where compile time
is the compile time of generated classes).
|
void |
registerExcludedResource(java.lang.String path)
Registers a resource path as excluded.
|
void |
registerGeneratedResource(java.lang.String path,
java.util.function.Consumer<? super java.io.File> consumer)
Registers a new generated resource.
|
void |
registerGeneratedSourceFile(com.squareup.javapoet.JavaFile javaFile)
Registers a generated source file.
|
void |
registerStaticInitializer(com.squareup.javapoet.MethodSpec staticInitializer)
Registers a code block to be executed statically when
the optimized binary is loaded.
|
public DelegatingSourceGenerationContext(AOTContext delegate)
@NonNull public java.lang.String getPackageName()
AOTContext
getPackageName
in interface AOTContext
@NonNull public Configuration getConfiguration()
AOTContext
getConfiguration
in interface AOTContext
@NonNull public ApplicationContextAnalyzer getAnalyzer()
AOTContext
getAnalyzer
in interface AOTContext
public void registerGeneratedSourceFile(@NonNull com.squareup.javapoet.JavaFile javaFile)
AOTContext
registerGeneratedSourceFile
in interface AOTContext
javaFile
- the file to be added.public void registerStaticInitializer(com.squareup.javapoet.MethodSpec staticInitializer)
AOTContext
registerStaticInitializer
in interface AOTContext
staticInitializer
- the static initializer methodpublic void registerGeneratedResource(@NonNull java.lang.String path, java.util.function.Consumer<? super java.io.File> consumer)
AOTContext
registerGeneratedResource
in interface AOTContext
path
- the relative path to the resource (including file name)consumer
- the consumer to be called when the resource is generated.public void registerExcludedResource(@NonNull java.lang.String path)
AOTContext
registerExcludedResource
in interface AOTContext
path
- the path of the resource to excludepublic void registerClassNeededAtCompileTime(@NonNull java.lang.Class<?> clazz)
AOTContext
registerClassNeededAtCompileTime
in interface AOTContext
clazz
- a class@NonNull public com.squareup.javapoet.JavaFile javaFile(com.squareup.javapoet.TypeSpec typeSpec)
AOTContext
javaFile
in interface AOTContext
typeSpec
- the type spec of the main class@NonNull public void addDiagnostics(java.lang.String category, java.lang.String message)
AOTContext
addDiagnostics
in interface AOTContext
category
- a category for the message, typically corresponding
to the source generator typemessage
- a message to logpublic <T> void put(@NonNull java.lang.Class<T> type, @NonNull T value)
AOTContext
put
in interface AOTContext
T
- the type of the valuetype
- the class of the value to storevalue
- the value to store@NonNull public <T> java.util.Optional<T> get(@NonNull java.lang.Class<T> type)
AOTContext
get
in interface AOTContext
T
- the type of the entrytype
- the class of the entry@NonNull public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getDiagnostics()
AOTContext
getDiagnostics
in interface AOTContext
@NonNull public Runtime getRuntime()
AOTContext
getRuntime
in interface AOTContext