It seems Selma does not provide native support to convert an array of BeanSource to an array of BeanDestination
But it works fine from a List<BeanSource> to a List<BeanDestination>.
Code below does not compile:
public class BeanSource {
private int foo;
public int getFoo() {
return this.foo;
}
public void setFoo(int foo) {
this.foo = foo;
}
}
public class BeanDestination {
private int foo;
public int getFoo() {
return foo;
}
public void setFoo(int foo) {
this.foo = foo;
}
}
public class ArrayBeanSource {
private BeanSource beans[];
public BeanSource[] getBeans() {
return this.beans;
}
public void setBeans(BeanSource beans[]) {
this.beans = beans;
}
}
public class ArrayBeanDestination {
private BeanDestination beans[];
public BeanDestination[] getBeans() {
return this.beans;
}
public void setBeans(BeanDestination beans[]) {
this.beans = beans;
}
}
@Mapper(withIoC = IoC.SPRING)
public interface BeanMapper {
ArrayBeanDestination asArrayBeanDestination(ArrayBeanSource in);
}
I somehow manage to workaround the problem with an abstract mapper
@Mapper(withIoC = IoC.SPRING)
public abstract class AbstractBeanMapper {
public abstract BeanDestination asBeanDestination(BeanSource in);
public abstract ArrayBeanDestination asArrayBeanDestination(ArrayBeanSource in);
public BeanDestination[] asBeanDestination(BeanSource[] in) {
if (in == null) {
return null;
}
return Arrays.stream(in).map(this::asBeanDestination).toArray(BeanDestination[]::new);
}
}
Could it be possible for Selma to handle this natively ?
We do not always have the possibility to change the BeanSource or BeanDestination implemention.
The text was updated successfully, but these errors were encountered:
It seems Selma does not provide native support to convert an array of BeanSource to an array of BeanDestination
But it works fine from a
List<BeanSource>
to aList<BeanDestination>
.Code below does not compile:
I somehow manage to workaround the problem with an abstract mapper
Could it be possible for Selma to handle this natively ?
We do not always have the possibility to change the BeanSource or BeanDestination implemention.
The text was updated successfully, but these errors were encountered: