
@SupportedAnnotationTypes(value="org.mapstruct.Mapper") @SupportedOptions(value={"mapstruct.suppressGeneratorTimestamp","mapstruct.suppressGeneratorVersionInfoComment","mapstruct.unmappedTargetPolicy","mapstruct.defaultComponentModel","mapstruct.defaultInjectionStrategy","mapstruct.verbose"}) public class MappingProcessor extends 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, gems as generated with help of the Hickory tool are used. These gems 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 String |
ALWAYS_GENERATE_SERVICE_FILE |
protected static String |
DEFAULT_COMPONENT_MODEL |
protected static String |
DEFAULT_INJECTION_STRATEGY |
protected static String |
SUPPRESS_GENERATOR_TIMESTAMP |
protected static String |
SUPPRESS_GENERATOR_VERSION_INFO_COMMENT |
protected static String |
UNMAPPED_TARGET_POLICY |
protected static String |
VERBOSE |
processingEnv| Constructor and Description |
|---|
MappingProcessor() |
| Modifier and Type | Method and Description |
|---|---|
SourceVersion |
getSupportedSourceVersion() |
void |
init(ProcessingEnvironment processingEnv) |
boolean |
process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) |
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, isInitializedprotected static final String SUPPRESS_GENERATOR_TIMESTAMP
protected static final String SUPPRESS_GENERATOR_VERSION_INFO_COMMENT
protected static final String UNMAPPED_TARGET_POLICY
protected static final String DEFAULT_COMPONENT_MODEL
protected static final String DEFAULT_INJECTION_STRATEGY
protected static final String ALWAYS_GENERATE_SERVICE_FILE
protected static final String VERBOSE
public void init(ProcessingEnvironment processingEnv)
init in interface Processorinit in class AbstractProcessorpublic SourceVersion getSupportedSourceVersion()
getSupportedSourceVersion in interface ProcessorgetSupportedSourceVersion in class AbstractProcessorpublic boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment)
process in interface Processorprocess in class AbstractProcessorCopyright © 2012-2021 MapStruct Authors; All rights reserved. Released under the Apache Software License 2.0.