Hello!
First of all: JMapper is a great Lib, Thank you for all your work and this Google Group!
My problem or feature request:
I want to map a nested field by using a conversion (i read that automatic mapping was requested earlier for nested fields). Here some sample code:
public class Source {
private String field;
private FieldWrapper fieldWrapper;
public Source(String field, FieldWrapper fieldWrapper) {
this.field = field;
this.fieldWrapper = fieldWrapper;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public Boolean getWrappedField() {
return fieldWrapper.getWrappedField();
}
public void setWrappedField(Boolean wrappedField) {
fieldWrapper.setWrappedField(wrappedField);
}
}
public class FieldWrapper {
protected Boolean wrappedField;
public FieldWrapper(Boolean wrappedField) {
this.wrappedField = wrappedField;
}
public Boolean getWrappedField() {
return wrappedField;
}
public void setWrappedField(Boolean wrappedField) {
this.wrappedField = wrappedField;
}
}
public class Destination {
@JMap
private String field;
@JMap("fieldWrapper")
private Boolean unwrappedField;
@JMapConversion(from={"fieldWrapper"}, to={"unwrappedField"})
public Boolean convert(FieldWrapper fieldWrapper) {
return fieldWrapper.getWrappedField();
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public Boolean getUnwrappedField() {
return unwrappedField;
}
public void setUnwrappedField(Boolean unwrappedField) {
this.unwrappedField = unwrappedField;
}
}
Console:
com.googlecode.jmapper.exceptions.MalformedBeanException: getFieldWrapper method not found in Source Class for the fieldWrapper field, checks the signature.
Now the problem is exactly what the message says, although i have written a converter, it is not used since the fieldWrapper cannot be accessed. When i change my @JMap("fieldWrapper") to @JMap("wrappedField"), for which a getter exists, JMapper is complaining that the field does not exist in the source-class: com.googlecode.jmapper.exceptions.MappingErrorException: incorrect configuration of the unwrappedField field in Destination Class: the wrappedField field doesn't exist in Source Class
This is all correct behavior but i need to get around that since I am not allowed to (or shouldn't) make any changes to the source-class. What could i do besides manually mapping the field?
Best, Alex