Skip to content

Commit 81da6c5

Browse files
author
eugenp
committed
cleanup work
1 parent e83b4b8 commit 81da6c5

File tree

15 files changed

+538
-565
lines changed

15 files changed

+538
-565
lines changed

dozer-tutorial/pom.xml

+51-52
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,58 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.baeldung</groupId>
5-
<artifactId>dozer-tutorial</artifactId>
6-
<version>1.0</version>
7-
<name>Dozer</name>
8-
<build>
9-
<plugins>
10-
<plugin>
11-
<groupId>org.apache.maven.plugins</groupId>
12-
<artifactId>maven-compiler-plugin</artifactId>
13-
<version>3.3</version>
14-
<configuration>
15-
<source>7</source>
16-
<target>7</target>
17-
</configuration>
18-
</plugin>
19-
</plugins>
20-
</build>
21-
<dependencies>
22-
<dependency>
23-
<groupId>org.slf4j</groupId>
24-
<artifactId>slf4j-api</artifactId>
25-
<version>1.7.5</version>
26-
</dependency>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.baeldung</groupId>
6+
<artifactId>dozer-tutorial</artifactId>
7+
<version>1.0</version>
8+
9+
<name>dozer</name>
2710

28-
<dependency>
29-
<groupId>org.slf4j</groupId>
30-
<artifactId>jcl-over-slf4j</artifactId>
31-
<version>1.7.5</version>
32-
</dependency>
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<groupId>org.apache.maven.plugins</groupId>
15+
<artifactId>maven-compiler-plugin</artifactId>
16+
<version>3.3</version>
17+
<configuration>
18+
<source>7</source>
19+
<target>7</target>
20+
</configuration>
21+
</plugin>
22+
</plugins>
23+
</build>
3324

34-
<dependency>
35-
<groupId>org.apache.commons</groupId>
36-
<artifactId>commons-lang3</artifactId>
37-
<version>3.2.1</version>
38-
</dependency>
25+
<dependencies>
26+
<dependency>
27+
<groupId>org.slf4j</groupId>
28+
<artifactId>slf4j-api</artifactId>
29+
<version>1.7.5</version>
30+
</dependency>
3931

40-
<dependency>
41-
<groupId>commons-beanutils</groupId>
42-
<artifactId>commons-beanutils</artifactId>
43-
<version>1.9.1</version>
44-
</dependency>
32+
<dependency>
33+
<groupId>org.slf4j</groupId>
34+
<artifactId>jcl-over-slf4j</artifactId>
35+
<version>1.7.5</version>
36+
</dependency>
4537

46-
<dependency>
47-
<groupId>net.sf.dozer</groupId>
48-
<artifactId>dozer</artifactId>
49-
<version>5.5.1</version>
50-
</dependency>
51-
<dependency>
52-
<groupId>junit</groupId>
53-
<artifactId>junit</artifactId>
54-
<version>4.3</version>
55-
<scope>test</scope>
56-
</dependency>
38+
<dependency>
39+
<groupId>org.apache.commons</groupId>
40+
<artifactId>commons-lang3</artifactId>
41+
<version>3.2.1</version>
42+
</dependency>
5743

58-
</dependencies>
44+
<dependency>
45+
<groupId>net.sf.dozer</groupId>
46+
<artifactId>dozer</artifactId>
47+
<version>5.5.1</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>junit</groupId>
51+
<artifactId>junit</artifactId>
52+
<version>4.3</version>
53+
<scope>test</scope>
54+
</dependency>
55+
56+
</dependencies>
57+
5958
</project>
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package com.baeldung.dozer;
22

33
public class Dest {
4-
private String name;
5-
private int age;
4+
private String name;
5+
private int age;
66

7-
public Dest() {
7+
public Dest() {
88

9-
}
9+
}
1010

11-
public Dest(String name, int age) {
12-
super();
13-
this.name = name;
14-
this.age = age;
15-
}
11+
public Dest(String name, int age) {
12+
super();
13+
this.name = name;
14+
this.age = age;
15+
}
1616

17-
public String getName() {
18-
return name;
19-
}
17+
public String getName() {
18+
return name;
19+
}
2020

21-
public void setName(String name) {
22-
this.name = name;
23-
}
21+
public void setName(String name) {
22+
this.name = name;
23+
}
2424

25-
public int getAge() {
26-
return age;
27-
}
25+
public int getAge() {
26+
return age;
27+
}
2828

29-
public void setAge(int age) {
30-
this.age = age;
31-
}
29+
public void setAge(int age) {
30+
this.age = age;
31+
}
3232

3333
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
package com.baeldung.dozer;
22

33
public class Dest2 {
4-
private int id;
5-
private int points;
4+
private int id;
5+
private int points;
66

7-
public Dest2() {
7+
public Dest2() {
88

9-
}
9+
}
1010

11-
public Dest2(int id, int points) {
12-
super();
13-
this.id = id;
14-
this.points = points;
15-
}
11+
public Dest2(int id, int points) {
12+
super();
13+
this.id = id;
14+
this.points = points;
15+
}
1616

17-
public int getId() {
18-
return id;
19-
}
17+
public int getId() {
18+
return id;
19+
}
2020

21-
public void setId(int id) {
22-
this.id = id;
23-
}
21+
public void setId(int id) {
22+
this.id = id;
23+
}
2424

25-
public int getPoints() {
26-
return points;
27-
}
25+
public int getPoints() {
26+
return points;
27+
}
2828

29-
public void setPoints(int points) {
30-
this.points = points;
31-
}
29+
public void setPoints(int points) {
30+
this.points = points;
31+
}
3232

33-
@Override
34-
public String toString() {
35-
return "Dest2 [id=" + id + ", points=" + points + "]";
36-
}
33+
@Override
34+
public String toString() {
35+
return "Dest2 [id=" + id + ", points=" + points + "]";
36+
}
3737

3838
}

dozer-tutorial/src/main/java/com/baeldung/dozer/MyCustomConvertor.java

+30-34
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,35 @@
1010

1111
public class MyCustomConvertor implements CustomConverter {
1212

13-
@Override
14-
public Object convert(Object dest, Object source, Class<?> arg2,
15-
Class<?> arg3) {
16-
if (source == null) {
17-
return null;
18-
}
19-
if (source instanceof Personne3) {
20-
Personne3 person = (Personne3) source;
21-
Date date = new Date(person.getDtob());
22-
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
23-
String isoDate = format.format(date);
24-
return new Person3(person.getName(), isoDate);
25-
26-
} else if (source instanceof Person3) {
27-
Person3 person = (Person3) source;
28-
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
29-
Date date = null;
30-
try {
31-
date = format.parse(person.getDtob());
32-
33-
} catch (ParseException e) {
34-
throw new MappingException("Converter MyCustomConvertor "
35-
+ "used incorrectly:" + e.getMessage());
36-
}
37-
long timestamp = date.getTime();
38-
return new Personne3(person.getName(), timestamp);
39-
40-
} else {
41-
throw new MappingException("Converter MyCustomConvertor "
42-
+ "used incorrectly. Arguments passed in were:" + dest
43-
+ " and " + source);
44-
45-
}
46-
}
13+
@Override
14+
public Object convert(Object dest, Object source, Class<?> arg2, Class<?> arg3) {
15+
if (source == null) {
16+
return null;
17+
}
18+
if (source instanceof Personne3) {
19+
Personne3 person = (Personne3) source;
20+
Date date = new Date(person.getDtob());
21+
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
22+
String isoDate = format.format(date);
23+
return new Person3(person.getName(), isoDate);
24+
25+
} else if (source instanceof Person3) {
26+
Person3 person = (Person3) source;
27+
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
28+
Date date = null;
29+
try {
30+
date = format.parse(person.getDtob());
31+
32+
} catch (ParseException e) {
33+
throw new MappingException("Converter MyCustomConvertor " + "used incorrectly:" + e.getMessage());
34+
}
35+
long timestamp = date.getTime();
36+
return new Personne3(person.getName(), timestamp);
37+
38+
} else {
39+
throw new MappingException("Converter MyCustomConvertor " + "used incorrectly. Arguments passed in were:" + dest + " and " + source);
40+
41+
}
42+
}
4743

4844
}
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
package com.baeldung.dozer;
22

33
public class Person {
4-
private String name;
5-
private String nickname;
6-
private int age;
4+
private String name;
5+
private String nickname;
6+
private int age;
77

8-
public Person() {
8+
public Person() {
99

10-
}
10+
}
1111

12-
public Person(String name, String nickname, int age) {
13-
super();
14-
this.name = name;
15-
this.nickname = nickname;
16-
this.age = age;
17-
}
12+
public Person(String name, String nickname, int age) {
13+
super();
14+
this.name = name;
15+
this.nickname = nickname;
16+
this.age = age;
17+
}
1818

19-
public String getName() {
20-
return name;
21-
}
19+
public String getName() {
20+
return name;
21+
}
2222

23-
public void setName(String name) {
24-
this.name = name;
25-
}
23+
public void setName(String name) {
24+
this.name = name;
25+
}
2626

27-
public String getNickname() {
28-
return nickname;
29-
}
27+
public String getNickname() {
28+
return nickname;
29+
}
3030

31-
public void setNickname(String nickname) {
32-
this.nickname = nickname;
33-
}
31+
public void setNickname(String nickname) {
32+
this.nickname = nickname;
33+
}
3434

35-
public int getAge() {
36-
return age;
37-
}
35+
public int getAge() {
36+
return age;
37+
}
3838

39-
public void setAge(int age) {
40-
this.age = age;
41-
}
39+
public void setAge(int age) {
40+
this.age = age;
41+
}
4242

4343
}

0 commit comments

Comments
 (0)