AdvancedPayment.java

package com.tradecloud.domain.shipment.clearing;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.common.Currency;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;
import java.util.Objects;

@Entity
public class AdvancedPayment extends PersistenceBase {
    private BigDecimal amount;
    private String reference;
    @ManyToOne
    private Currency currency;

    public AdvancedPayment() {
    }

    public AdvancedPayment(BigDecimal amount, String reference, Currency currency) {
        this.amount = amount;
        this.reference = reference;
        this.currency = currency;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public Currency getCurrency() {
        return currency;
    }

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

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AdvancedPayment that = (AdvancedPayment) o;
        return Objects.equals(amount, that.amount) &&
                Objects.equals(reference, that.reference) &&
                Objects.equals(currency, that.currency);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), amount, reference, currency);
    }
}