View Javadoc
1   package io.oasp.module.beanmapping.common.impl.dozer;
2   
3   import io.oasp.module.beanmapping.common.base.AbstractBeanMapper;
4   
5   import javax.inject.Inject;
6   import javax.inject.Named;
7   
8   import org.dozer.Mapper;
9   
10  /**
11   * This is the implementation of {@link io.oasp.module.beanmapping.common.api.BeanMapper} using dozer {@link Mapper}.
12   *
13   * @author hohwille
14   * @since 1.3.0
15   */
16  @Named
17  public class BeanMapperImplDozer extends AbstractBeanMapper {
18  
19    /** The dozer instance to use. */
20    private Mapper dozer;
21  
22    /**
23     * The constructor.
24     */
25    public BeanMapperImplDozer() {
26  
27      super();
28    }
29  
30    /**
31     * @param dozer is the {@link Mapper} to {@link Inject}.
32     */
33    @Inject
34    public void setDozer(Mapper dozer) {
35  
36      this.dozer = dozer;
37    }
38  
39    @Override
40    public <T> T map(Object source, Class<T> targetClass) {
41  
42      if (source == null) {
43        return null;
44      }
45      return this.dozer.map(source, targetClass);
46    }
47  
48  }