RatesResponse.java

package com.tradecloud.domain.exchangerate;

import com.tradecloud.domain.model.Money;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "RatesReponse")
public class RatesResponse {

    private Money spotRate;
    private Money forwardRate;
    private String message;

    public RatesResponse() {
    }

    public RatesResponse(Money spotRate, Money forwardRate, String message) {
        this.spotRate = spotRate;
        this.forwardRate = forwardRate;
        this.message = message;
    }

    public static RatesResponse valueOf(Money spotRate, Money forwardRate) {
        return new RatesResponse(spotRate, forwardRate, null);
    }

    public static RatesResponse valueOf(Money spotRate, Money forwardRate, String message) {
        return new RatesResponse(spotRate, forwardRate, message);
    }

    public Money getForwardRate() {
        return forwardRate;
    }

    public Money getSpotRate() {
        return spotRate;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RatesResponse other = (RatesResponse) obj;
        if ((this.spotRate == null || !this.spotRate.equals(other.spotRate))) {
            return false;
        }
        if ((this.forwardRate == null || !this.forwardRate.equals(other.forwardRate))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.spotRate != null ? this.spotRate.hashCode() : 0);
        hash = 59 * hash + (this.forwardRate != null ? this.forwardRate.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "RatesResponse{" +
                "forwardRate=" + forwardRate +
                ", spotRate=" + spotRate +
                ", message='" + message + '\'' +
                '}';
    }
}