All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.uol.pagseguro.api.common.domain.converterXML.PhonesV2XMLConverter Maven / Gradle / Ivy

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 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 phoneAccountList) {
        ArrayList phoneList = new ArrayList();

        for (PhoneAccount phoneAccount : phoneAccountList) {
            PhoneV2XMLConverter phone = new PhoneV2XMLConverter(
                phoneAccount.getType(), phoneAccount.getAreaCode(), phoneAccount.getNumber()
            );
            phoneList.add(phone);
        }

        return phoneList;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy