I have this class over here, and I was wondering how would one go about creating a value object, for this class. Please note I want to be able to compare two reports, so that two reports are only equal if and only if all the contents inside the arrays, name and commission are also equal.
So my value object would need to override the equals method.
Concrete Class
public class ReportImpl implements Report {
private String name;
private double commissionPerEmployee;
private double[] legalData;
private double[] cashFlowData;
private double[] mergesData;
private double[] tallyingData;
private double[] deductionsData;
public ReportImpl(String name,
double commissionPerEmployee,
double[] legalData,
double[] cashFlowData,
double[] mergesData,
double[] tallyingData,
double[] deductionsData) {
this.name = name;
this.commissionPerEmployee = commissionPerEmployee;
this.legalData = legalData;
this.cashFlowData = cashFlowData;
this.mergesData = mergesData;
this.tallyingData = tallyingData;
this.deductionsData = deductionsData;
}
@Override
public String getReportName() {
return name;
}
@Override
public double getCommission() {
return commissionPerEmployee;
}
@Override
public double[] getLegalData() {
return legalData;
}
@Override
public double[] getCashFlowData() {
return cashFlowData;
}
@Override
public double[] getMergesData() {
return mergesData;
}
@Override
public double[] getTallyingData() {
return tallyingData;
}
@Override
public double[] getDeductionsData() {
return deductionsData;
}
@Override
public String toString() {
return String.format("%s", name);
}
}
public interface Report {
/*
* Note from Tim: You would think you could use reportName as an id, but there's more than
* 1700 cases of duplicate name in the database where the marketing guys decided to call
* literally the same accounting work 10 different things (with different prices)
*/
String getReportName();
double getCommission();
double[] getLegalData();
double[] getCashFlowData();
double[] getMergesData();
double[] getTallyingData();
double[] getDeductionsData();
}
Aucun commentaire:
Enregistrer un commentaire