| Conditions | 10 |
| Total Lines | 20 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Complex classes like it.cnr.istc.pst.cognition.koala.reasoner.environment.parser.xml.Sensor.equals(Object) often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | package it.cnr.istc.pst.cognition.koala.reasoner.environment.parser.xml; |
||
| 100 | @Override |
||
| 101 | public boolean equals(Object obj) { |
||
| 102 | if (this == obj) |
||
| 103 | return true; |
||
| 104 | if (obj == null) |
||
| 105 | return false; |
||
| 106 | if (getClass() != obj.getClass()) |
||
| 107 | return false; |
||
| 108 | Sensor other = (Sensor) obj; |
||
| 109 | if (id == null) { |
||
| 110 | if (other.id != null) |
||
| 111 | return false; |
||
| 112 | } else if (!id.equals(other.id)) |
||
| 113 | return false; |
||
| 114 | if (name == null) { |
||
| 115 | if (other.name != null) |
||
| 116 | return false; |
||
| 117 | } else if (!name.equals(other.name)) |
||
| 118 | return false; |
||
| 119 | return true; |
||
| 120 | } |
||
| 130 |