Class OfficeFloorJavaCompilerImpl
- java.lang.Object
-
- net.officefloor.compile.classes.OfficeFloorJavaCompiler
-
- net.officefloor.compile.impl.classes.OfficeFloorJavaCompilerImpl
-
public class OfficeFloorJavaCompilerImpl extends OfficeFloorJavaCompiler
OfficeFloorJavaCompiler
implementation.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.compile.classes.OfficeFloorJavaCompiler
OfficeFloorJavaCompiler.ClassField, OfficeFloorJavaCompiler.ClassName, OfficeFloorJavaCompiler.ConstructorWriter, OfficeFloorJavaCompiler.ConstructorWriterContext, OfficeFloorJavaCompiler.ImplementationRunnable<T extends java.lang.Throwable>, OfficeFloorJavaCompiler.JavaSource, OfficeFloorJavaCompiler.JavaSourceContext, OfficeFloorJavaCompiler.JavaSourceWriter, OfficeFloorJavaCompiler.MethodWriter, OfficeFloorJavaCompiler.MethodWriterContext, OfficeFloorJavaCompiler.NonCompilerOperation<T extends java.lang.Throwable>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
JAVAC_PROCESSING_ENVIRONMENT_CLASS_NAME
Class
name for the JavacProcessingEnvironment to confirm on class path to ensure can compile.-
Fields inherited from class net.officefloor.compile.classes.OfficeFloorJavaCompiler
DEFAULT_OFFICE_FLOOR_JAVA_COMPILER_IMPLEMENTATION, SYSTEM_PROPERTY_JAVA_COMPILING
-
-
Constructor Summary
Constructors Constructor Description OfficeFloorJavaCompilerImpl(SourceContext sourceContext)
Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OfficeFloorJavaCompiler.JavaSource
addSource(java.lang.String className, java.lang.String source)
OfficeFloorJavaCompiler.JavaSource
addWrapper(java.lang.Class<?>[] wrappingTypes, java.lang.Class<?> delegateType, java.lang.String delegateExtraction, OfficeFloorJavaCompiler.ConstructorWriter constructorWriter, OfficeFloorJavaCompiler.MethodWriter methodWriter, OfficeFloorJavaCompiler.JavaSourceWriter... additionalSourceWriter)
Adds a wrapperOfficeFloorJavaCompiler.JavaSource
.java.util.Map<OfficeFloorJavaCompiler.JavaSource,java.lang.Class<?>>
compile()
Compiles all the addedOfficeFloorJavaCompiler.JavaSource
instances.OfficeFloorJavaCompiler.ClassName
createClassName(java.lang.String name)
Generates a uniqueOfficeFloorJavaCompiler.ClassName
.OfficeFloorJavaCompiler.ClassField
createField(java.lang.Class<?> fieldType, java.lang.String fieldName)
Creates theOfficeFloorJavaCompiler.ClassField
.java.lang.String
getSourceName(java.lang.Class<?> type)
Obtains the source name for theClass
.void
writeConstructor(java.lang.Appendable appendable, java.lang.String className, OfficeFloorJavaCompiler.ClassField... fields)
Writes theConstructor
.void
writeDelegateMethodCall(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method)
Writes the delegateMethod
call.void
writeMethodImplementation(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method)
Writes theMethod
implementation by invoking the delegate.boolean
writeMethodSignature(java.lang.Appendable source, java.lang.reflect.Method method)
Writes theMethod
signature to theAppendable
.-
Methods inherited from class net.officefloor.compile.classes.OfficeFloorJavaCompiler
addSource, addWrapper, newInstance, runWithImplementation, runWithoutCompiler
-
-
-
-
Field Detail
-
JAVAC_PROCESSING_ENVIRONMENT_CLASS_NAME
public static final java.lang.String JAVAC_PROCESSING_ENVIRONMENT_CLASS_NAME
Class
name for the JavacProcessingEnvironment to confirm on class path to ensure can compile.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OfficeFloorJavaCompilerImpl
public OfficeFloorJavaCompilerImpl(SourceContext sourceContext) throws java.lang.ClassNotFoundException
Instantiate.- Parameters:
sourceContext
-SourceContext
.- Throws:
java.lang.ClassNotFoundException
- If missingClass
instances for compiling.
-
-
Method Detail
-
createClassName
public OfficeFloorJavaCompiler.ClassName createClassName(java.lang.String name)
Description copied from class:OfficeFloorJavaCompiler
Generates a uniqueOfficeFloorJavaCompiler.ClassName
.- Specified by:
createClassName
in classOfficeFloorJavaCompiler
- Parameters:
name
- Seed name.- Returns:
OfficeFloorJavaCompiler.ClassName
.
-
getSourceName
public java.lang.String getSourceName(java.lang.Class<?> type)
Description copied from class:OfficeFloorJavaCompiler
Obtains the source name for theClass
.- Specified by:
getSourceName
in classOfficeFloorJavaCompiler
- Parameters:
type
-Class
.- Returns:
- Name used in source to reference the type.
-
createField
public OfficeFloorJavaCompiler.ClassField createField(java.lang.Class<?> fieldType, java.lang.String fieldName)
Description copied from class:OfficeFloorJavaCompiler
Creates theOfficeFloorJavaCompiler.ClassField
.- Specified by:
createField
in classOfficeFloorJavaCompiler
- Parameters:
fieldType
-Field
type.fieldName
-Field
name.- Returns:
OfficeFloorJavaCompiler.ClassField
.
-
writeConstructor
public void writeConstructor(java.lang.Appendable appendable, java.lang.String className, OfficeFloorJavaCompiler.ClassField... fields) throws java.io.IOException
Description copied from class:OfficeFloorJavaCompiler
Writes theConstructor
.- Specified by:
writeConstructor
in classOfficeFloorJavaCompiler
- Parameters:
appendable
-Appendable
.className
- Simple name of theClass
.fields
-OfficeFloorJavaCompiler.ClassField
instances.- Throws:
java.io.IOException
- If fails to write theConstructor
.
-
writeMethodSignature
public boolean writeMethodSignature(java.lang.Appendable source, java.lang.reflect.Method method) throws java.io.IOException
Description copied from class:OfficeFloorJavaCompiler
Writes theMethod
signature to theAppendable
.- Specified by:
writeMethodSignature
in classOfficeFloorJavaCompiler
- Parameters:
source
-Appendable
.method
-Method
.- Returns:
true
if returns a value (false
forvoid
Method
return).- Throws:
java.io.IOException
- If fails to write theMethod
signature.
-
writeMethodImplementation
public void writeMethodImplementation(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method) throws java.io.IOException
Description copied from class:OfficeFloorJavaCompiler
Writes theMethod
implementation by invoking the delegate.- Specified by:
writeMethodImplementation
in classOfficeFloorJavaCompiler
- Parameters:
source
-Appendable
.delegate
- Means to access delegate.method
-Method
.- Throws:
java.io.IOException
- If fails write delegateMethod
implementation.
-
writeDelegateMethodCall
public void writeDelegateMethodCall(java.lang.Appendable source, java.lang.String delegate, java.lang.reflect.Method method) throws java.io.IOException
Description copied from class:OfficeFloorJavaCompiler
Writes the delegateMethod
call.- Specified by:
writeDelegateMethodCall
in classOfficeFloorJavaCompiler
- Parameters:
source
-Appendable
.delegate
- Means to access delegate.method
-Method
.- Throws:
java.io.IOException
- If fails write delegateMethod
call.
-
addSource
public OfficeFloorJavaCompiler.JavaSource addSource(java.lang.String className, java.lang.String source)
Description copied from class:OfficeFloorJavaCompiler
- Specified by:
addSource
in classOfficeFloorJavaCompiler
- Parameters:
className
-Class
name.source
- Source for theClass
.- Returns:
OfficeFloorJavaCompiler.JavaSource
.
-
addWrapper
public OfficeFloorJavaCompiler.JavaSource addWrapper(java.lang.Class<?>[] wrappingTypes, java.lang.Class<?> delegateType, java.lang.String delegateExtraction, OfficeFloorJavaCompiler.ConstructorWriter constructorWriter, OfficeFloorJavaCompiler.MethodWriter methodWriter, OfficeFloorJavaCompiler.JavaSourceWriter... additionalSourceWriter) throws java.io.IOException
Description copied from class:OfficeFloorJavaCompiler
Adds a wrapperOfficeFloorJavaCompiler.JavaSource
.- Specified by:
addWrapper
in classOfficeFloorJavaCompiler
- Parameters:
wrappingTypes
- Wrapping types.delegateType
- Delegate type.delegateExtraction
- Means to extract the wrapped implementation from the delegate. May benull
to use default.constructorWriter
-OfficeFloorJavaCompiler.ConstructorWriter
. May benull
to use defaultConstructor
.methodWriter
-OfficeFloorJavaCompiler.MethodWriter
. May benull
to use default implementation.additionalSourceWriter
-OfficeFloorJavaCompiler.JavaSourceWriter
instances.- Returns:
OfficeFloorJavaCompiler.JavaSource
for the wrapper.- Throws:
java.io.IOException
- If fails to write the wrapper.
-
compile
public java.util.Map<OfficeFloorJavaCompiler.JavaSource,java.lang.Class<?>> compile()
Description copied from class:OfficeFloorJavaCompiler
Compiles all the addedOfficeFloorJavaCompiler.JavaSource
instances.- Specified by:
compile
in classOfficeFloorJavaCompiler
- Returns:
Map
ofOfficeFloorJavaCompiler.JavaSource
to itsClass
.
-
-