Renaming to MapStruct

This commit is contained in:
Gunnar Morling 2013-02-27 00:58:41 +01:00
parent 7fc0878673
commit df6ae29f2d
35 changed files with 100 additions and 95 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 Gunnar Morling (http://www.gunnarmorling.de/)
Copyright 2012-2013 Gunnar Morling (http://www.gunnarmorling.de/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,15 +21,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.moapa.maple</groupId>
<artifactId>maple-parent</artifactId>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>maple</artifactId>
<artifactId>mapstruct</artifactId>
<packaging>jar</packaging>
<name>Maple Core</name>
<name>MapStruct Core</name>
<dependencies>
<dependency>

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;
package org.mapstruct;
public class Mappers {

View File

@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;
package org.mapstruct;
import de.moapa.maple.converter.Converter;
import de.moapa.maple.converter.NoOpConverter;
import org.mapstruct.converter.Converter;
import org.mapstruct.converter.NoOpConverter;
public @interface Mapping {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;
package org.mapstruct;
public @interface Mappings {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.converter;
package org.mapstruct.converter;
public interface Converter<S, T> {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.converter;
package org.mapstruct.converter;
public class NoOpConverter implements Converter<Object, Object> {

View File

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;
package org.mapstruct;
import de.moapa.maple.test.model.Foo;
import org.mapstruct.Mappers;
import org.mapstruct.test.model.Foo;
import org.testng.annotations.Test;
import static org.fest.assertions.Assertions.assertThat;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.test.model;
package org.mapstruct.test.model;
public interface Foo {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.test.model;
package org.mapstruct.test.model;
public class FooImpl implements Foo {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 Gunnar Morling (http://www.gunnarmorling.de/)
Copyright 2012-2013 Gunnar Morling (http://www.gunnarmorling.de/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -20,13 +20,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.moapa.maple</groupId>
<artifactId>maple-parent</artifactId>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maple Parent</name>
<url>https://github.com/gunnarmorling/maple</url>
<name>MapStruct Parent</name>
<url>https://github.com/gunnarmorling/mapstruct</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -52,7 +52,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>maple</artifactId>
<artifactId>mapstruct</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

10
pom.xml
View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 Gunnar Morling (http://www.gunnarmorling.de/)
Copyright 2012-2013 Gunnar Morling (http://www.gunnarmorling.de/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -22,15 +22,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.moapa.maple</groupId>
<artifactId>maple-parent</artifactId>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>parent/pom.xml</relativePath>
</parent>
<artifactId>maple-aggregator</artifactId>
<artifactId>mapstruct-aggregator</artifactId>
<packaging>pom</packaging>
<name>Maple-Aggregator</name>
<name>MapStruct Aggregator</name>
<modules>
<module>parent</module>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 Gunnar Morling (http://www.gunnarmorling.de/)
Copyright 2012-2013 Gunnar Morling (http://www.gunnarmorling.de/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,15 +21,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.moapa.maple</groupId>
<artifactId>maple-parent</artifactId>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>maple-processor</artifactId>
<artifactId>mapstruct-processor</artifactId>
<packaging>jar</packaging>
<name>Maple Processor</name>
<name>MapStruct Processor</name>
<dependencies>
<dependency>
@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>maple</artifactId>
<artifactId>mapstruct</artifactId>
<scope>test</scope>
</dependency>

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap;
package org.mapstruct.ap;
import java.beans.Introspector;
import java.io.IOException;
@ -41,16 +41,17 @@ import javax.lang.model.util.SimpleAnnotationValueVisitor6;
import javax.lang.model.util.Types;
import javax.tools.JavaFileObject;
import de.moapa.maple.ap.model.BeanMapping;
import de.moapa.maple.ap.model.Mapper;
import de.moapa.maple.ap.model.MappingMethod;
import de.moapa.maple.ap.model.PropertyMapping;
import de.moapa.maple.ap.model.Type;
import de.moapa.maple.ap.model.source.MappedProperty;
import de.moapa.maple.ap.model.source.Mapping;
import de.moapa.maple.ap.model.source.Method;
import de.moapa.maple.ap.model.source.Parameter;
import de.moapa.maple.ap.writer.ModelWriter;
import org.mapstruct.ap.model.BeanMapping;
import org.mapstruct.ap.model.Mapper;
import org.mapstruct.ap.model.MappingMethod;
import org.mapstruct.ap.model.PropertyMapping;
import org.mapstruct.ap.model.Type;
import org.mapstruct.ap.model.source.MappedProperty;
import org.mapstruct.ap.model.source.Mapping;
import org.mapstruct.ap.model.source.Method;
import org.mapstruct.ap.model.source.Parameter;
import org.mapstruct.ap.writer.ModelWriter;
import static javax.lang.model.util.ElementFilter.methodsIn;
@ -58,8 +59,8 @@ public class MapperGenerationVisitor extends ElementKindVisitor6<Void, Void> {
private final static String IMPLEMENTATION_SUFFIX = "Impl";
private final static String MAPPING_ANNOTATION = "de.moapa.maple.Mapping";
private final static String MAPPINGS_ANNOTATION = "de.moapa.maple.Mappings";
private final static String MAPPING_ANNOTATION = "org.mapstruct.Mapping";
private final static String MAPPINGS_ANNOTATION = "org.mapstruct.Mappings";
private final ProcessingEnvironment processingEnvironment;
private final Types typeUtils;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap;
package org.mapstruct.ap;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
@ -25,7 +25,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("de.moapa.maple.Mapper")
@SupportedAnnotationTypes("org.mapstruct.Mapper")
public class MappingProcessor extends AbstractProcessor {
/**

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model;
package org.mapstruct.ap.model;
import java.util.List;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model;
package org.mapstruct.ap.model;
import java.util.List;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model;
package org.mapstruct.ap.model;
public class MappingMethod {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model;
package org.mapstruct.ap.model;
public class PropertyMapping {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model;
package org.mapstruct.ap.model;
/**
* Represents the type of a bean property, parameter etc.

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model.source;
package org.mapstruct.ap.model.source;
import de.moapa.maple.ap.model.Type;
import org.mapstruct.ap.model.Type;
public class MappedProperty {

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model.source;
package org.mapstruct.ap.model.source;
import de.moapa.maple.ap.model.Type;
import org.mapstruct.ap.model.Type;
public class Mapping {

View File

@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model.source;
package org.mapstruct.ap.model.source;
import java.util.List;
import de.moapa.maple.ap.model.Type;
import org.mapstruct.ap.model.Type;
public class Method {

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.model.source;
package org.mapstruct.ap.model.source;
import de.moapa.maple.ap.model.Type;
import org.mapstruct.ap.model.Type;
public class Parameter {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.writer;
package org.mapstruct.ap.writer;
import java.io.BufferedWriter;
import javax.tools.JavaFileObject;

View File

@ -1 +1 @@
de.moapa.maple.ap.MappingProcessor
org.mapstruct.ap.MappingProcessor

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test;
package org.mapstruct.ap.test;
import java.io.File;
import java.util.ArrayList;
@ -22,12 +22,12 @@ import java.util.List;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaFileObject;
import de.moapa.maple.ap.test.model.Car;
import de.moapa.maple.ap.test.model.CarDto;
import de.moapa.maple.ap.test.model.IntToStringConverter;
import de.moapa.maple.ap.test.model.CarMapper;
import de.moapa.maple.ap.test.model.Person;
import de.moapa.maple.ap.test.model.PersonDto;
import org.mapstruct.ap.test.model.Car;
import org.mapstruct.ap.test.model.CarDto;
import org.mapstruct.ap.test.model.CarMapper;
import org.mapstruct.ap.test.model.IntToStringConverter;
import org.mapstruct.ap.test.model.Person;
import org.mapstruct.ap.test.model.PersonDto;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@ -38,7 +38,7 @@ public class CarMapperTest extends MapperTestBase {
private DiagnosticCollector<JavaFileObject> diagnostics;
public CarMapperTest() {
super( "maple.jar" );
super( "mapstruct.jar" );
}
@BeforeMethod

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test;
package org.mapstruct.ap.test;
import java.io.File;
import java.io.IOException;
@ -31,7 +31,7 @@ import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
import de.moapa.maple.ap.MappingProcessor;
import org.mapstruct.ap.MappingProcessor;
import org.testng.annotations.BeforeClass;
public abstract class MapperTestBase {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test.model;
package org.mapstruct.ap.test.model;
import java.util.ArrayList;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test.model;
package org.mapstruct.ap.test.model;
import java.util.ArrayList;

View File

@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test.model;
package org.mapstruct.ap.test.model;
import java.util.ArrayList;
import de.moapa.maple.Mapper;
import de.moapa.maple.Mappers;
import de.moapa.maple.Mapping;
import de.moapa.maple.Mappings;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
@Mapper
public interface CarMapper {

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test.model;
package org.mapstruct.ap.test.model;
import de.moapa.maple.converter.Converter;
import org.mapstruct.converter.Converter;
public class IntToStringConverter implements Converter<Integer, String> {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test.model;
package org.mapstruct.ap.test.model;
public class Person {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.ap.test.model;
package org.mapstruct.ap.test.model;
public class PersonDto {

View File

@ -1,8 +1,8 @@
# What's Maple?
# What's MapStruct?
Maple is a Java [annotation processor](http://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html) for the generation of type-safe bean mapping classes.
MapStruct is a Java [annotation processor](http://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html) for the generation of type-safe bean mapping classes.
All you have to do is to define one more more mapper interfaces, annotate them with the `@Mapper` annotation and add the required mapping methods. During compilation, Maple will generate an implementation for each mapper interface, based on your preferred mapping framework (currently [Dozer](http://dozer.sourceforge.net/) is supported, more to come).
All you have to do is to define one more more mapper interfaces, annotate them with the `@Mapper` annotation and add the required mapping methods. During compilation, MapStruct will generate an implementation for each mapper interface, based on your preferred mapping framework (currently [Dozer](http://dozer.sourceforge.net/) is supported, more to come).
The following shows an example. First, an object (e.g. a JPA entity) and an accompanying data transfer object (DTO):
@ -39,7 +39,7 @@ Both types are rather similar, only the seat count attributes have different nam
The interface is straight-forward:
* Annotating it with `@Mapper` let's the Maple processor kick in during compilation
* Annotating it with `@Mapper` let's the MapStruct processor kick in during compilation
* The `INSTANCE` member provides access to the mapper implementation for clients (a service loader based alternative coming soon)
* For each mapping direction (entity to DTO and vice versa) there is a conversion method. For those attributes which have differing names and thus can't be mapped automatically, a mapping is configured using the `@Mapping` annotation on one of the methods.
@ -92,21 +92,21 @@ To make use of a converter, specify its type within the `@Mapping` annotation:
Car carDtoToCar(CarDto carDto);
}
# Using Maple
# Using MapStruct
Maple is a Java annotation processor based on [JSR 269](jcp.org/en/jsr/detail?id=269) and as such can be used within command line builds (javac, Ant, Maven etc.) as well as from within your IDE.
MapStruct is a Java annotation processor based on [JSR 269](jcp.org/en/jsr/detail?id=269) and as such can be used within command line builds (javac, Ant, Maven etc.) as well as from within your IDE.
Detailed instructions on the usage will be added soon, in between the [set up](http://docs.jboss.org/hibernate/stable/jpamodelgen/reference/en-US/html/chapter-usage.html) of the Hibernate JPA meta model generator can be used as general guideline for setting up an annotation processor.
In order to use Maple, you have to check out its sources as it is currently not available in any public Maven repository.
In order to use MapStruct, you have to check out its sources as it is currently not available in any public Maven repository.
# What's next
Maple is just in its very beginnings. There are several ideas for further features, including but not limited to:
MapStruct is just in its very beginnings. There are several ideas for further features, including but not limited to:
* Allow to generate mappers for several existing mapping frameworks (currently only Dozer is supported).
* Generate "native" mappers, that is without any reflection, but by direcly invoking getters and setters within the generated mapper. This should deliver very efficient mapper implementations
* Provide a way to access the underlying mapper in order to make use of advanced features not provided by the Maple API (similar to the `unwrap()` method of JPA etc.)
* Provide a way to access the underlying mapper in order to make use of advanced features not provided by the MapStruct API (similar to the `unwrap()` method of JPA etc.)
* Provide a way to add custom mapping code in a very simple way
Example:
@ -133,4 +133,4 @@ Example:
}
}
* Remove runtime dependencies to Maple by using the JDK service loader to retrieve mapper implementations.
* Remove runtime dependencies to MapStruct by using the JDK service loader to retrieve mapper implementations.