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

com.adyen.model.marketpay.AccountTransactionList Maven / Gradle / Ivy

There is a newer version: 28.4.0
Show newest version
/*
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * Adyen Java API Library
 *
 * Copyright (c) 2017 Adyen B.V.
 * This file is open source and available under the MIT license.
 * See the LICENSE file for more info.
 */
package com.adyen.model.marketpay;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;

/**
 * AccountTransactionList
 */
public class AccountTransactionList {
    @SerializedName("accountCode")
    private String accountCode = null;

    @SerializedName("hasNextPage")
    private Boolean hasNextPage = null;

    @SerializedName("transactions")
    private List transactionContainers = null;

    private transient List transactions = null;

    public AccountTransactionList accountCode(String accountCode) {
        this.accountCode = accountCode;
        return this;
    }

    /**
     * The code of the account
     *
     * @return accountCode
     **/
    public String getAccountCode() {
        return accountCode;
    }

    public void setAccountCode(String accountCode) {
        this.accountCode = accountCode;
    }

    public AccountTransactionList hasNextPage(Boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
        return this;
    }

    /**
     * Flag determines if there is next page available
     *
     * @return hasNextPage
     **/
    public Boolean getHasNextPage() {
        return hasNextPage;
    }

    public void setHasNextPage(Boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
    }

    public AccountTransactionList transactionContainers(List transactionContainers) {
        this.transactionContainers = transactionContainers;
        return this;
    }

    public AccountTransactionList addTransactionContainerItem(TransactionContainer transactionContainerItem) {
        this.transactionContainers.add(transactionContainerItem);
        return this;
    }

    /**
     * Populate the virtual transactions to bypass the transactionContainers list
     *
     * @return transactions
     **/
    public List getTransactions() {
        if (transactions == null) {
            transactions = new ArrayList();
            if (transactionContainers != null && ! transactionContainers.isEmpty()) {
                for (TransactionContainer transactionContainer : transactionContainers) {
                    transactions.add(transactionContainer.getTransaction());
                }
            }
        }
        return transactions;
    }

    /**
     * Creating a new transactions list
     * @param transactions transactions
     */
    public void setTransactions(List transactions) {

        this.transactions = transactions;

        // set as well the container list this will be send in the API request
        this.transactionContainers = new ArrayList();

        for (Transaction transaction : transactions) {

            TransactionContainer transactionContainer = new TransactionContainer(transaction);
            this.transactionContainers.add(transactionContainer);
        }
    }

    public AccountTransactionList addTransaction(Transaction transaction) {
        TransactionContainer transactionContainer = new TransactionContainer(transaction);

        if (transactionContainers == null) {
            transactionContainers = new ArrayList();
        }
        this.transactionContainers.add(transactionContainer);

        if (transactions == null) {
            transactions = new ArrayList();
        }
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        AccountTransactionList accountTransactionList = (AccountTransactionList) o;
        return Objects.equals(this.accountCode, accountTransactionList.accountCode)
                && Objects.equals(this.hasNextPage, accountTransactionList.hasNextPage)
                && Objects.equals(this.transactionContainers, accountTransactionList.transactionContainers);
    }

    @Override
    public int hashCode() {
        return Objects.hash(accountCode, hasNextPage, transactionContainers);
    }


    @Override
    public String toString() {
        // Populate the accounts list to provide back in the toString() method
        this.getTransactions();
        StringBuilder sb = new StringBuilder();
        sb.append("class AccountTransactionList {\n");

        sb.append("    accountCode: ").append(toIndentedString(accountCode)).append("\n");
        sb.append("    hasNextPage: ").append(toIndentedString(hasNextPage)).append("\n");
        sb.append("    transactions: ").append(toIndentedString(transactions)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy