Confirmation.java
package com.tradecloud.domain.model.fec;
import com.tradecloud.domain.model.ForexGroup;
import com.tradecloud.domain.model.Money;
import com.tradecloud.domain.model.organisationalunit.OrganisationalUnit;
import org.joda.time.LocalDate;
/**
* A value object which contains fields captured in order to be compared against
* an FEC for the purpose of preforming a validity check.
* <p>
* The main reason for having this object is to avoid the need for extremely
* long method signatures in order to confirm a FEC.
*/
public abstract class Confirmation {
protected FECConfirmationType confirmationType;
private Money amount;
private LocalDate maturityDate;
private Money spotRate;
private Money forwardRate;
private BankReference bankReference;
private OrganisationalUnit organisationalUnit;
private ForexGroup forexGroup;
protected Confirmation(BankReference bankReference, Money amount, LocalDate maturityDate, Money spotRate, Money forwardRate,
OrganisationalUnit organisationalUnit, ForexGroup forexGroup) {
this.amount = amount;
this.maturityDate = maturityDate;
this.spotRate = spotRate;
this.forwardRate = forwardRate;
this.bankReference = bankReference;
this.organisationalUnit = organisationalUnit;
this.forexGroup = forexGroup;
}
public FECConfirmationType getConfirmationType() {
return confirmationType;
}
public Money getAmount() {
return amount;
}
public Money getForwardRate() {
return forwardRate;
}
public LocalDate getMaturityDate() {
return maturityDate;
}
public Money getSpotRate() {
return spotRate;
}
public BankReference getBankReference() {
return bankReference;
}
public OrganisationalUnit getOrganisationalUnit() {
return organisationalUnit;
}
public ForexGroup getForexGroup() {
return forexGroup;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Confirmation other = (Confirmation) obj;
if (this.amount != other.amount && (this.amount == null || !this.amount.equals(other.amount))) {
return false;
}
if (this.maturityDate != other.maturityDate && (this.maturityDate == null || !this.maturityDate.equals(other.maturityDate))) {
return false;
}
if (this.spotRate != other.spotRate && (this.spotRate == null || !this.spotRate.equals(other.spotRate))) {
return false;
}
if (this.forwardRate != other.forwardRate && (this.forwardRate == null || !this.forwardRate.equals(other.forwardRate))) {
return false;
}
if (this.bankReference != other.bankReference && (this.bankReference == null || !this.bankReference.equals(other.bankReference))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 61 * hash + (this.amount != null ? this.amount.hashCode() : 0);
hash = 61 * hash + (this.maturityDate != null ? this.maturityDate.hashCode() : 0);
hash = 61 * hash + (this.spotRate != null ? this.spotRate.hashCode() : 0);
hash = 61 * hash + (this.forwardRate != null ? this.forwardRate.hashCode() : 0);
hash = 61 * hash + (this.bankReference != null ? this.bankReference.hashCode() : 0);
return hash;
}
}