io.oasp.module.beanmapping.common.base.AbstractBeanMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oasp4j-beanmapping Show documentation
Show all versions of oasp4j-beanmapping Show documentation
Minimal shim for bean mapping to convert between compatible Java beans (e.g. JPA entity to transfer-object and vice versa).
package io.oasp.module.beanmapping.common.base;
import io.oasp.module.beanmapping.common.api.BeanMapper;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* The abstract base implementation of {@link BeanMapper}.
*
* @author hohwille
*/
public abstract class AbstractBeanMapper implements BeanMapper {
/**
* The constructor.
*/
public AbstractBeanMapper() {
super();
}
/**
* {@inheritDoc}
*/
@Override
public List mapList(List> source, Class targetClass) {
if ((source == null) || (source.isEmpty())) {
return new ArrayList<>();
}
List result = new ArrayList<>(source.size());
for (Object sourceObject : source) {
result.add(map(sourceObject, targetClass));
}
return result;
}
/**
* {@inheritDoc}
*/
@Override
public Set mapSet(Set> source, Class targetClass) {
if ((source == null) || (source.isEmpty())) {
return new HashSet<>();
}
Set result = new HashSet<>(source.size());
for (Object sourceObject : source) {
result.add(map(sourceObject, targetClass));
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy