I have a long list of object mapping to do from classes auto generated by JAXB.
customer.setCustomerId(rentalCustomer.getCustomerid().getValue()));
customer.setCustomerName(rentalCustomer.getTradingname().getValue());
customer.setVatNumber(rentalSearchCustomer.getVatNumber().getValue());
....
....
Basically I need to make a null check for ALL fields:
getValue(RentalCustomerIDType idType){
if(idType != null){
return idType.getValue();
}
else {
return "";
}
}
Problem is there are too many of these and they all have different types: RentalCustomerIDType, TradingType, VatNumberType..etc
Is there an elegant way to this by creating a GENERIC method that makes null check and return proper values for ALL maybe using Functional Libraries for Java?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…