Skip to content
Permalink
Browse files

Initial import

  • Loading branch information...
gunnarmorling committed May 28, 2012
0 parents commit 61f181a589564131b1a540e5322ec63d56604870
Showing with 1,241 additions and 0 deletions.
  1. +14 −0 .gitignore
  2. +13 −0 core/etc/license.txt
  3. +46 −0 core/pom.xml
  4. +20 −0 core/src/main/java/de/moapa/maple/Mapper.java
  5. +45 −0 core/src/main/java/de/moapa/maple/Mappers.java
  6. +20 −0 core/src/main/java/de/moapa/maple/Mapping.java
  7. +31 −0 core/src/test/java/de/moapa/maple/MappersTest.java
  8. +20 −0 core/src/test/java/de/moapa/maple/test/model/Foo.java
  9. +20 −0 core/src/test/java/de/moapa/maple/test/model/FooImpl.java
  10. +13 −0 etc/license.txt
  11. +13 −0 parent/etc/license.txt
  12. +121 −0 parent/pom.xml
  13. +40 −0 pom.xml
  14. +13 −0 processor/etc/license.txt
  15. +97 −0 processor/pom.xml
  16. +140 −0 processor/src/main/java/de/moapa/maple/ap/MapperGenerationVisitor.java
  17. +77 −0 processor/src/main/java/de/moapa/maple/ap/MappingProcessor.java
  18. +52 −0 processor/src/main/java/de/moapa/maple/ap/model/Mapper.java
  19. +41 −0 processor/src/main/java/de/moapa/maple/ap/model/MapperMethod.java
  20. +35 −0 processor/src/main/java/de/moapa/maple/ap/model/Parameter.java
  21. +36 −0 processor/src/main/java/de/moapa/maple/ap/model/Type.java
  22. +1 −0 processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor
  23. +36 −0 processor/src/main/resources/dozer-mapper-implementation.ftl
  24. +201 −0 processor/src/test/java/de/moapa/maple/ap/test/CarMapperTest.java
  25. +33 −0 processor/src/test/java/de/moapa/maple/ap/test/model/Car.java
  26. +36 −0 processor/src/test/java/de/moapa/maple/ap/test/model/CarDto.java
  27. +27 −0 processor/src/test/java/de/moapa/maple/ap/test/model/CarMapper.java
@@ -0,0 +1,14 @@
# Eclipse
.metadata
.classpath
.project
.settings

# IntelliJ
*.iml
*.ipr
*.iws

# Build
target
test-output
@@ -0,0 +1,13 @@
Copyright 2012 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.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>

<parent>
<groupId>de.moapa.maple</groupId>
<artifactId>maple-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<artifactId>maple</artifactId>
<packaging>jar</packaging>
<name>Maple Core</name>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,20 @@
/**
* Copyright 2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;

public @interface Mapper {

}
@@ -0,0 +1,45 @@
/**
* Copyright 2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;


public class Mappers {

private final static String IMPLEMENTATION_SUFFIX = "Impl";

/**
* TODO: Check that
* - clazz is an interface
* - the implementation type implements clazz
* - clazz is annotated with @Mapper
*
* TODO: Use privileged action
*/
@SuppressWarnings("unchecked")
public static <T> T getMapper(Class<T> clazz) {
try {

// ClassLoader classLoader = clazz.getClassLoader();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

return (T) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX ).newInstance();
}
catch ( Exception e ) {
e.printStackTrace();
throw new RuntimeException( e );
}
}
}
@@ -0,0 +1,20 @@
/**
* Copyright 2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;

public @interface Mapping {

}
@@ -0,0 +1,31 @@
/**
* Copyright 2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple;

import de.moapa.maple.test.model.Foo;
import org.testng.annotations.Test;

import static org.fest.assertions.Assertions.assertThat;

public class MappersTest {

@Test
public void shouldReturnImplementationInstance() {

Foo mapper = Mappers.getMapper( Foo.class );
assertThat( mapper ).isNotNull();
}
}
@@ -0,0 +1,20 @@
/**
* Copyright 2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.test.model;

public interface Foo {

}
@@ -0,0 +1,20 @@
/**
* Copyright 2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.moapa.maple.test.model;

public class FooImpl implements Foo {

}
@@ -0,0 +1,13 @@
Copyright 2012 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.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1,13 @@
Copyright 2012 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.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Maple Parent</name>
<url>https://github.com/gunnarmorling/maple</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.14</version>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.3.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.10</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>maple</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
<header>etc/license.txt</header>
<strictCheck>true</strictCheck>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Oops, something went wrong.

0 comments on commit 61f181a

Please sign in to comment.
You can’t perform that action at this time.