File tree 2 files changed +39
-0
lines changed
src/main/java/org/diningdevelopers/service
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 325
325
<artifactId >httpclient</artifactId >
326
326
<version >4.2.2</version >
327
327
</dependency >
328
+ <dependency >
329
+ <groupId >net.sf.dozer</groupId >
330
+ <artifactId >dozer</artifactId >
331
+ <version >5.4.0</version >
332
+ </dependency >
328
333
</dependencies >
329
334
330
335
<repositories >
Original file line number Diff line number Diff line change
1
+ package org .diningdevelopers .service ;
2
+
3
+ import java .util .ArrayList ;
4
+ import java .util .Collection ;
5
+ import java .util .List ;
6
+
7
+ import javax .enterprise .context .ApplicationScoped ;
8
+
9
+ import org .dozer .DozerBeanMapper ;
10
+ import org .dozer .Mapper ;
11
+
12
+ @ ApplicationScoped
13
+ public class MappingService {
14
+
15
+ private Mapper mapper = new DozerBeanMapper ();
16
+
17
+ public <S , D > void map (S source , D destination ) {
18
+ mapper .map (source , destination );
19
+ }
20
+
21
+ public <S , D > D map (S source , Class <D > destinationClass ) {
22
+ return mapper .map (source , destinationClass );
23
+ }
24
+
25
+ public <S , D > List <D > mapCollection (Collection <S > sourceList , Class <D > destinationClass ) {
26
+ List <D > list = new ArrayList <D >();
27
+
28
+ for (S source : sourceList ) {
29
+ list .add (mapper .map (source , destinationClass ));
30
+ }
31
+
32
+ return list ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments