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

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

The newest version!
package br.com.uol.pagseguro.api.common.domain.converterXML;

import br.com.uol.pagseguro.api.common.domain.Document;

import java.util.ArrayList;
import java.util.List;

public class DocumentsV2XMLConverter {

    private ArrayList document;

    public ArrayList getDocument() {
        if (document == null) {
            document = new ArrayList();
        }
        return document;
    }

    public void setDocument(ArrayList document) {
        this.document = document;
    }

    /**
     * Convert attributes in request XML
     *
     * @param documentAccountList Document data
     * @see Document
     * @return DocumentsV2XMLConverter
     */
    public DocumentsV2XMLConverter convert(List documentAccountList) {
        DocumentsV2XMLConverter convertedDocument = new DocumentsV2XMLConverter();
        convertedDocument.setDocument(parseToDocumentList(documentAccountList));
        return convertedDocument;
    }

    /**
     * Parse a Document list to a list of converted documents
     *
     * @param documentsList List of Document
     * @see Document
     * @return ArrayList List of converted documents
     */
    private ArrayList parseToDocumentList(List documentsList) {
        ArrayList documentList = new ArrayList();

        for (Document document : documentsList) {
            DocumentV2XMLConverter documentConverter = new DocumentV2XMLConverter(
                document.getType().toString(), document.getValue()
            );
            documentList.add(documentConverter);
        }

        return documentList;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy