forked from I2P_Developers/i2p.i2p
Change the Rate.equals(..) method to work for Rates w/o a parent RateStat
Change the RateStat.equals(..) method to work with deserialized RateStats Update and fix the JUnit tests for both
This commit is contained in:
@ -533,10 +533,13 @@ public class Rate {
|
||||
if ((obj == null) || !(obj instanceof Rate)) return false;
|
||||
if (obj == this) return true;
|
||||
Rate r = (Rate) obj;
|
||||
return _period == r.getPeriod() && _creationDate == r.getCreationDate() &&
|
||||
// do this the easy way to avoid NPEs.
|
||||
// Alternative: compare name and group name (very carefully to avoid NPEs)
|
||||
_stat == r._stat;
|
||||
if (_period != r.getPeriod() || _creationDate != r.getCreationDate())
|
||||
return false;
|
||||
if (_stat == null && r._stat == null)
|
||||
return true;
|
||||
if (_stat != null && r._stat != null)
|
||||
return _stat.nameGroupDescEquals(r._stat);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,13 +166,16 @@ public class RateStat {
|
||||
if (obj == this)
|
||||
return true;
|
||||
RateStat rs = (RateStat) obj;
|
||||
if (DataHelper.eq(getGroupName(), rs.getGroupName()) && DataHelper.eq(getDescription(), rs.getDescription())
|
||||
&& DataHelper.eq(getName(), rs.getName())) {
|
||||
if (nameGroupDescEquals(rs))
|
||||
return deepEquals(this._rates, rs._rates);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean nameGroupDescEquals(RateStat rs) {
|
||||
return DataHelper.eq(getGroupName(), rs.getGroupName()) && DataHelper.eq(getDescription(), rs.getDescription())
|
||||
&& DataHelper.eq(getName(), rs.getName());
|
||||
}
|
||||
|
||||
public void store(OutputStream out, String prefix) throws IOException {
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
|
Reference in New Issue
Block a user