Slight equals simplifications (findbugs).

This commit is contained in:
Mike Pope 2019-03-25 14:58:03 +10:30
parent 118eefe605
commit 5ed02eb52d
11 changed files with 54 additions and 76 deletions

View File

@ -194,13 +194,11 @@ public class ColonyTradeItem extends TradeItem {
*/
@Override
public boolean equals(Object o) {
if (o instanceof ColonyTradeItem) {
ColonyTradeItem other = (ColonyTradeItem)o;
return Utils.equals(this.colonyId, other.colonyId)
&& Utils.equals(this.colonyName, other.colonyName)
&& super.equals(other);
}
return false;
if (!(o instanceof ColonyTradeItem)) return false;
ColonyTradeItem other = (ColonyTradeItem)o;
return Utils.equals(this.colonyId, other.colonyId)
&& Utils.equals(this.colonyName, other.colonyName)
&& super.equals(other);
}
/**

View File

@ -174,12 +174,10 @@ public class InciteTradeItem extends TradeItem {
*/
@Override
public boolean equals(Object o) {
if (o instanceof InciteTradeItem) {
InciteTradeItem other = (InciteTradeItem)o;
return Utils.equals(this.victim, other.victim)
&& super.equals(other);
}
return false;
if (!(o instanceof InciteTradeItem)) return false;
InciteTradeItem other = (InciteTradeItem)o;
return Utils.equals(this.victim, other.victim)
&& super.equals(other);
}
/**

View File

@ -225,13 +225,11 @@ public class NativeTradeItem extends GoodsTradeItem {
*/
@Override
public boolean equals(Object o) {
if (o instanceof NativeTradeItem) {
NativeTradeItem other = (NativeTradeItem)o;
return this.price == other.price
&& this.haggleCount == other.haggleCount
&& super.equals(other);
}
return false;
if (!(o instanceof NativeTradeItem)) return false;
NativeTradeItem other = (NativeTradeItem)o;
return this.price == other.price
&& this.haggleCount == other.haggleCount
&& super.equals(other);
}
/**

View File

@ -294,13 +294,11 @@ public abstract class TradeItem extends FreeColGameObject {
*/
@Override
public boolean equals(Object o) {
if (o instanceof TradeItem) {
TradeItem other = (TradeItem)o;
return Utils.equals(this.source, other.source)
&& Utils.equals(this.destination, other.destination)
&& super.equals(other);
}
return false;
if (!(o instanceof TradeItem)) return false;
TradeItem other = (TradeItem)o;
return Utils.equals(this.source, other.source)
&& Utils.equals(this.destination, other.destination)
&& super.equals(other);
}
/**

View File

@ -458,13 +458,11 @@ public final class AIGoods extends TransportableAIObject {
*/
@Override
public boolean equals(Object o) {
if (o instanceof AIGoods) {
AIGoods other = (AIGoods)o;
return Utils.equals(this.goods, other.goods)
&& Utils.equals(this.destination, other.destination)
&& super.equals(other);
}
return false;
if (!(o instanceof AIGoods)) return false;
AIGoods other = (AIGoods)o;
return Utils.equals(this.goods, other.goods)
&& Utils.equals(this.destination, other.destination)
&& super.equals(other);
}
/**

View File

@ -939,13 +939,11 @@ if (direction == null && !result) net.sf.freecol.FreeCol.trace(logger, "LTFAIL")
*/
@Override
public boolean equals(Object o) {
if (o instanceof AIUnit) {
AIUnit other = (AIUnit)o;
return Utils.equals(this.unit, other.unit)
&& Utils.equals(this.mission, other.mission)
&& super.equals(other);
}
return false;
if (!(o instanceof AIUnit)) return false;
AIUnit other = (AIUnit)o;
return Utils.equals(this.unit, other.unit)
&& Utils.equals(this.mission, other.mission)
&& super.equals(other);
}
/**

View File

@ -265,13 +265,11 @@ public final class GoodsWish extends Wish {
*/
@Override
public boolean equals(Object o) {
if (o instanceof GoodsWish) {
GoodsWish other = (GoodsWish)o;
return this.amountRequested == other.amountRequested
&& Utils.equals(this.goodsType, other.goodsType)
&& super.equals(other);
}
return false;
if (!(o instanceof GoodsWish)) return false;
GoodsWish other = (GoodsWish)o;
return this.amountRequested == other.amountRequested
&& Utils.equals(this.goodsType, other.goodsType)
&& super.equals(other);
}
/**

View File

@ -363,14 +363,12 @@ public class TileImprovementPlan extends ValuedAIObject {
*/
@Override
public boolean equals(Object o) {
if (o instanceof TileImprovementPlan) {
TileImprovementPlan other = (TileImprovementPlan)o;
return Utils.equals(this.type, other.type)
&& Utils.equals(this.target, other.target)
&& Utils.equals(this.pioneer, other.pioneer)
&& super.equals(other);
}
return false;
if (!(o instanceof TileImprovementPlan)) return false;
TileImprovementPlan other = (TileImprovementPlan)o;
return Utils.equals(this.type, other.type)
&& Utils.equals(this.target, other.target)
&& Utils.equals(this.pioneer, other.pioneer)
&& super.equals(other);
}
/**

View File

@ -397,12 +397,10 @@ public abstract class TransportableAIObject extends ValuedAIObject {
*/
@Override
public boolean equals(Object o) {
if (o instanceof TransportableAIObject) {
TransportableAIObject other = (TransportableAIObject)o;
return Utils.equals(this.transport, other.transport)
&& super.equals(other);
}
return false;
if (!(o instanceof TransportableAIObject)) return false;
TransportableAIObject other = (TransportableAIObject)o;
return Utils.equals(this.transport, other.transport)
&& super.equals(other);
}
/**

View File

@ -236,13 +236,11 @@ public abstract class Wish extends ValuedAIObject {
*/
@Override
public boolean equals(Object o) {
if (o instanceof Wish) {
Wish other = (Wish)o;
return Utils.equals(this.destination, other.destination)
&& Utils.equals(this.transportable, other.transportable)
&& super.equals(other);
}
return false;
if (!(o instanceof Wish)) return false;
Wish other = (Wish)o;
return Utils.equals(this.destination, other.destination)
&& Utils.equals(this.transportable, other.transportable)
&& super.equals(other);
}
/**

View File

@ -234,13 +234,11 @@ public final class WorkerWish extends Wish {
*/
@Override
public boolean equals(Object o) {
if (o instanceof WorkerWish) {
WorkerWish other = (WorkerWish)o;
return this.expertNeeded == other.expertNeeded
&& Utils.equals(this.unitType, other.unitType)
&& super.equals(other);
}
return false;
if (!(o instanceof WorkerWish)) return false;
WorkerWish other = (WorkerWish)o;
return this.expertNeeded == other.expertNeeded
&& Utils.equals(this.unitType, other.unitType)
&& super.equals(other);
}
/**