InterestRateResponse.java

package com.tradecloud.domain.exchangerate;

import com.tradecloud.domain.common.Currency;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.math.BigDecimal;

;

/**
 * Created by ds on 2016/03/03.
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "InterestRateResponse")
public class InterestRateResponse {

    private BigDecimal interestRate;
    private Currency currency;

    public InterestRateResponse(BigDecimal interestRate, Currency currency) {
        this.interestRate = interestRate;
        this.currency = currency;
    }

    public BigDecimal getInterestRate() {
        return interestRate;
    }

    public void setInterestRate(BigDecimal interestRate) {
        this.interestRate = interestRate;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    public String getStateAsXML() {
        StringBuilder builder = new StringBuilder();
        builder.append("<").append(this.getClass().getSimpleName().toLowerCase()).append(">");
        builder.append("<currency>").append((currency == null) ? "" : currency.toString()).append("</currency>");
        builder.append("<interestRate>").append(interestRate).append("</interestRate>");
        builder.append("</").append(this.getClass().getSimpleName().toLowerCase()).append(">");
        return builder.toString();
    }
}