| 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.Element.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; |
||
| 95 | @Override |
||
| 96 | public boolean equals(Object obj) { |
||
| 97 | if (this == obj) |
||
| 98 | return true; |
||
| 99 | if (obj == null) |
||
| 100 | return false; |
||
| 101 | if (getClass() != obj.getClass()) |
||
| 102 | return false; |
||
| 103 | Element other = (Element) obj; |
||
| 104 | if (id == null) { |
||
| 105 | if (other.id != null) |
||
| 106 | return false; |
||
| 107 | } else if (!id.equals(other.id)) |
||
| 108 | return false; |
||
| 109 | if (name == null) { |
||
| 110 | if (other.name != null) |
||
| 111 | return false; |
||
| 112 | } else if (!name.equals(other.name)) |
||
| 113 | return false; |
||
| 114 | return true; |
||
| 115 | } |
||
| 125 |