All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.godmonth.util.dozer.DozerTransformer Maven / Gradle / Ivy

package com.godmonth.util.dozer;

import org.apache.commons.collections4.Transformer;
import org.apache.commons.lang3.StringUtils;
import org.dozer.Mapper;

public class DozerTransformer implements Transformer {
	private Mapper mapper;
	private Class clazz;
	private final String mapId;

	public DozerTransformer(Mapper mapper, Class clazz) {
		this(mapper, clazz, null);
	}

	public DozerTransformer(Mapper mapper, Class clazz, String mapId) {
		this.mapper = mapper;
		this.clazz = clazz;
		this.mapId = mapId;
	}

	public OUT transform(Object input) {
		if (StringUtils.isNotBlank(mapId)) {
			return mapper.map(input, clazz, mapId);
		} else {
			return mapper.map(input, clazz);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy