Closed zhenyabodukhin closed 3 years ago
i use the JMap annotation and JMapAccessor when the list's name is larger, all the class attributes that you need should be tagged
like this
`
public class ArrayOfSomeClass{
@JMapAccessor(name = "aicr0P01V01S03", get = "getAICR0P01V01S03", set = "setAICR0P01V01S03")
@JMap
List
public List<AICR0P01V01S03> getAICR0P01V01S03(){
return aicr0P01V01S03;
}
public void setAICR0P01V01S03(List<AICR0P01V01S03> aicr0P01V01S03){
this.aicr0P01V01S03 = aicr0P01V01S03;
}
} `
` public class AICR0P01V01S03 {
@JMap private String codigoRetorno;
@JMap private Long cantidadRegistros;
@JMap private String valorConsultado;
/*
constructor
getter and setter
**/
} `
Thx for your comment, i will try add this. But my other List fields working ok without this annotation, i think, the problem is that JMapper do not use my method annotated with JMapConversion(@JMapConversion(from = {"vehicleAxleDetails"}, to = {"vehicleTyre"})), where i try to map some fields
i never used JMapConversoin, try using the JMapAccessor, this work when the list object has a larger name as VehicleAxleDetailsType
I have a problem. As you see below, I have tried to map Classes with Jmap Annotations, all working ok, except conversion method for List vehicleType field in destination class. Jmapper do not call this method and I get this field null. All required fields in Source.class have values. https://stackoverflow.com/questions/66273658/jmapper-conversoin-of-nested-fields-not-working
`public class Destination {
}
public class VehicleVariantDetailsType {
}
public class VehicleRunningGearDetailsType {
}
public class VehicleAxleDetailsType {
@JMap(value = "vehicleAxleDetails", classes = VehicleRunningGearDetails.class) protected List vehicleTyre;
@JMapConversion(from = {"vehicleAxleDetails"}, to = {"vehicleTyre"}) public List conversion2(List sourceList) {
List target = new ArrayList<>();
VehicleAxleDetails source = null;
if(!sourceList.isEmpty()) {
source = sourceList.get(0);
}
if(source!=null) {
VehicleTyreType dest = new VehicleTyreType();
dest.setVehicleTyreKindCode(source.getVehicleTyreKindCode());
dest.setVehicleTyreKindSize(source.getVehicleTyre().getVehicleTyreKindSize());
target.add(dest);
}
return target;
}
}
public class VehicleTyreType {
protected String vehicleTyreKindCode; protected String vehicleTyreKindSize; }
public class Source {
private List vehicleVariantDetails;
}
public class VehicleVariantDetails {
private VehicleRunningGearDetails vehicleRunningGearDetails; }
public class VehicleRunningGearDetails {
private List vehicleAxleDetails;
}
public class VehicleAxleDetails {
private String vehicleTyreKindCode; private VehicleTyre vehicleTyre; }
public class VehicleTyre {
private String vehicleTyreKindSize; }`