@SupportedAnnotationTypes(value="org.mapstruct.Mapper")
@SupportedOptions(value={"suppressGeneratorTimestamp","unmappedTargetPolicy","defaultComponentModel"})
public class MappingProcessor
extends javax.annotation.processing.AbstractProcessor
Processor which generates the implementations for mapper interfaces (interfaces
annotated with @Mapper).
Implementation notes:
The generation happens by incrementally building up a model representation of each mapper to be generated (a
Mapper object), which is then written into the resulting Java source file.
The model instantiation and processing happens in several phases/passes by applying a sequence of
ModelElementProcessors. The processors to apply are retrieved using the Java service loader mechanism and are
processed in order of their priority. The general processing flow is
this:
Mapper modelFor reading annotation attributes, prisms as generated with help of the Hickory tool are used. These prisms allow a comfortable access to annotations and their attributes without depending on their class objects.
The creation of Java source files is done using the FreeMarker template engine.
Each node of the mapper model has a corresponding FreeMarker template file which provides the Java representation of
that element and can include sub-elements via a custom FreeMarker directive. That way writing out a root node of the
model (Mapper) will recursively include all contained sub-elements (such as its methods, their property
mappings etc.).
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
DEFAULT_COMPONENT_MODEL |
protected static java.lang.String |
SUPPRESS_GENERATOR_TIMESTAMP |
protected static java.lang.String |
UNMAPPED_TARGET_POLICY |
| Constructor and Description |
|---|
MappingProcessor() |
| Modifier and Type | Method and Description |
|---|---|
javax.lang.model.SourceVersion |
getSupportedSourceVersion() |
void |
init(javax.annotation.processing.ProcessingEnvironment processingEnv) |
boolean |
process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
javax.annotation.processing.RoundEnvironment roundEnvironment) |
protected static final java.lang.String SUPPRESS_GENERATOR_TIMESTAMP
protected static final java.lang.String UNMAPPED_TARGET_POLICY
protected static final java.lang.String DEFAULT_COMPONENT_MODEL
public void init(javax.annotation.processing.ProcessingEnvironment processingEnv)
init in interface javax.annotation.processing.Processorinit in class javax.annotation.processing.AbstractProcessorpublic javax.lang.model.SourceVersion getSupportedSourceVersion()
getSupportedSourceVersion in interface javax.annotation.processing.ProcessorgetSupportedSourceVersion in class javax.annotation.processing.AbstractProcessorpublic boolean process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
javax.annotation.processing.RoundEnvironment roundEnvironment)
process in interface javax.annotation.processing.Processorprocess in class javax.annotation.processing.AbstractProcessorCopyright © 2012-2014. All Rights Reserved.