br.com.uol.pagseguro.api.common.domain.converterXML.PhonesV2XMLConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pagseguro-api Show documentation
Show all versions of pagseguro-api Show documentation
A collection of domain classes to ease integrations with PagSeguro Api
The newest version!
package br.com.uol.pagseguro.api.common.domain.converterXML;
import br.com.uol.pagseguro.api.common.domain.PhoneAccount;
import java.util.ArrayList;
import java.util.List;
public class PhonesV2XMLConverter {
private ArrayList phone;
public ArrayList getPhone() {
if (phone == null){
phone = new ArrayList();
}
return phone;
}
public void setPhone(ArrayList phone) {
this.phone = phone;
}
/**
* Convert attributes in request XML
*
* @param phoneAccountList Phone Account data
* @see PhoneAccount
* @return PhonesV2XMLConverter
*/
public PhonesV2XMLConverter convert(List extends PhoneAccount> phoneAccountList) {
PhonesV2XMLConverter convertedPhone = new PhonesV2XMLConverter();
convertedPhone.setPhone(parseToPhoneList(phoneAccountList));
return convertedPhone;
}
/**
* Parse a PhoneAccount list to a list of converted phone accounts
*
* @param phoneAccountList List of PhoneAccount
* @see PhoneAccount
* @return ArrayList List of converted phones
*/
private ArrayList parseToPhoneList(List extends PhoneAccount> phoneAccountList) {
ArrayList phoneList = new ArrayList();
for (PhoneAccount phoneAccount : phoneAccountList) {
PhoneV2XMLConverter phone = new PhoneV2XMLConverter(
phoneAccount.getType(), phoneAccount.getAreaCode(), phoneAccount.getNumber()
);
phoneList.add(phone);
}
return phoneList;
}
}