I'm have some problems when I'm trying use the Model Mapper in Java 8. I have a object "Person" and a object "Documents" I have a situation similar to this:
public class Doc {
private Integer type;
private List<Documento> documentos = null;
private Boolean flag;
}
public class Document {
private Long doc1;
private Long doc2;
private Long doc3;
}
public class Person {
private Integer type;
private Long doc1;
private Long doc2;
private Long doc3;
private Boolean flag;
}
modelMapper.addMappings(new PropertyMap<Person, Doc>() {
@Override
protected void configure() {
map().setType(source.getType());
map().setDoc1(source.getDocument().get(0).getDoc1().longValue());
map().setDoc2(source.getDocument().get(0).getDoc2().longValue());
map().setDoc3(source.getDocument().get(0).getDoc3().longValue());
map()setFlag(source.getFlag());
}
});
But, this don't work.
Invalid source method java.util.List.get(). Ensure that method has zero parameters and does not return void.
I need to just the first object of document list.
How can I resolve this ?