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

br.com.uol.pagseguro.api.application.authorization.PermissionsV2XMLConverter Maven / Gradle / Ivy

The newest version!
package br.com.uol.pagseguro.api.application.authorization;

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

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

public class PermissionsV2XMLConverter {

    private ArrayList code;

    public ArrayList getCode() {
        if (code == null) {
            code = new ArrayList();
        }
        return code;
    }

    public void setCode(ArrayList code) {
        this.code = code;
    }

    /**
     * Convert attributes in request XML
     *
     * @param codeList List of permission codes
     * @return PermissionsV2XMLConverter
     */
    public PermissionsV2XMLConverter convert(List codeList) {
        PermissionsV2XMLConverter convertedPermissions = new PermissionsV2XMLConverter();
        convertedPermissions.setCode(parseToCodeStringList(codeList));
        return convertedPermissions;
    }

    /**
     * Parse a permission codes list to a string list of codes
     *
     * @param codeList List of permission codes
     * @return ArrayList List of permission codes
     */
    private ArrayList parseToCodeStringList(List codeList) {
        ArrayList codeStringList = new ArrayList();
        for (PermissionCode.Code code : codeList) {
            codeStringList.add(code.getStringCode());
        }
        return codeStringList;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy