Class MappingProcessor
- All Implemented Interfaces:
Processor
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:
- retrieve mapping methods
- create the
Mappermodel - perform enrichments and modifications (e.g. add annotations for dependency injection)
- if no error occurred, write out the model into Java source files
For reading annotation attributes, gems as generated with help of Gem Tools. These gems allow 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.).
- Author:
- Gunnar Morling
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.protected static final StringDeprecated.Fields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinit(ProcessingEnvironment processingEnv) booleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment) Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, isInitialized
-
Field Details
-
SUPPRESS_GENERATOR_TIMESTAMP
Deprecated. -
SUPPRESS_GENERATOR_VERSION_INFO_COMMENT
Deprecated. -
UNMAPPED_TARGET_POLICY
Deprecated. -
UNMAPPED_SOURCE_POLICY
Deprecated. -
DEFAULT_COMPONENT_MODEL
Deprecated. -
DEFAULT_INJECTION_STRATEGY
Deprecated. -
ALWAYS_GENERATE_SERVICE_FILE
Deprecated. -
DISABLE_BUILDERS
Deprecated. -
VERBOSE
Deprecated. -
NULL_VALUE_ITERABLE_MAPPING_STRATEGY
Deprecated. -
NULL_VALUE_MAP_MAPPING_STRATEGY
Deprecated.
-
-
Constructor Details
-
MappingProcessor
public MappingProcessor()
-
-
Method Details
-
init
- Specified by:
initin interfaceProcessor- Overrides:
initin classAbstractProcessor
-
getSupportedSourceVersion
- Specified by:
getSupportedSourceVersionin interfaceProcessor- Overrides:
getSupportedSourceVersionin classAbstractProcessor
-
process
- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor
-
getSupportedOptions
- Specified by:
getSupportedOptionsin interfaceProcessor- Overrides:
getSupportedOptionsin classAbstractProcessor
-