Skip to content
This repository was archived by the owner on Jun 11, 2023. It is now read-only.

Commit 8ce8dd6

Browse files
committed
<master> Updated readme
1 parent 15f9229 commit 8ce8dd6

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,70 @@
11
# mapper-generator
22
An annotation processor for generating bean mappers
3+
4+
## IDE support
5+
This annotation processor is supported by Android Studio out-of-box.
6+
You have to set-up processor and generated code usage in your IntelliJ IDEA project.
7+
8+
9+
## Usage
10+
This processor generates mapper from getters to constructor args.
11+
12+
```java
13+
//gradle deps (don't forget to apply 'net.ltgt.apt' or other annotation plugin):
14+
dependencies {
15+
compile 'com.devindi.mapper:library:0.1'
16+
apt 'com.devindi.mapper:processor:0.1.1'
17+
}
18+
19+
//Source:
20+
public class PersonDto {
21+
22+
private String name;
23+
private int age;
24+
25+
//constructor, setters or other methods
26+
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public void setName(String name) {
32+
this.name = name;
33+
}
34+
}
35+
36+
//Target:
37+
public class Person {
38+
39+
private final String name;
40+
private final int age;
41+
42+
public Person(int age, String name) {
43+
this.name = name;
44+
this.age = age;
45+
}
46+
}
47+
48+
//Mapper definition:
49+
@Mapper
50+
public interface PersonMapper {
51+
Person toModel(PersonDto dto);
52+
}
53+
54+
//Generated code:
55+
public class PersonMapperImpl implements PersonMapper {
56+
@Override
57+
public Person toModel(PersonDto dto) {
58+
return new com.example.Person(dto.getAge(),dto.getName());
59+
}
60+
}
61+
```
62+
63+
64+
## ToDo list
65+
66+
* Type converters (String <-> Long, Double <-> Float, custom converters)
67+
* Collection mapping (List<Source> -> List<Target>)
68+
* Recursive mapping
69+
70+

0 commit comments

Comments
 (0)