You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ArrayList objects = new ArrayList();
...
DozerBeanMapper MAPPER = new DozerBeanMapper();
...
ArrayList newObjects = MAPPER.map(objects, ...);
like this
<S, D> Collection map(Collection srcCollection, Class targetClass);
not iterate over list
The text was updated successfully, but these errors were encountered:
Dozer should not do it because it copy bean to bean, so it is not it's task.
But it is quite simple to make a wrap class. I use this one in our project for example:
public class EntityConverter {
private Mapper mapper;
@Inject
public EntityConverter(Mapper mapper) {
this.mapper = mapper;
}
public <F, T> T fill(F source, T destination) {
if (source == null || destination == null) return null;
mapper.map(source, destination);
return destination;
}
public <F, T> List<T> convert(List<F> fromList, final Class<T> toClass) {
return Lists.transform(fromList, new Function<F, T>() {
@Override
public T apply(F from) {
return convert(from, toClass);
}
});
}
public <F, T> T convert(F from, final Class<T> toClass) {
if (from == null) return null;
return mapper.map(from, toClass);
}
}
ArrayList objects = new ArrayList();
...
DozerBeanMapper MAPPER = new DozerBeanMapper();
...
ArrayList newObjects = MAPPER.map(objects, ...);
like this
<S, D> Collection map(Collection
srcCollection, Class targetClass);not iterate over list
The text was updated successfully, but these errors were encountered: