|
14 | 14 |
|
15 | 15 | package org.eclipse.m2e.core.internal.lifecyclemapping.discovery;
|
16 | 16 |
|
| 17 | +import java.util.Objects; |
| 18 | + |
17 | 19 | import org.eclipse.core.runtime.Assert;
|
18 | 20 |
|
19 | 21 | import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
|
@@ -67,14 +69,7 @@ public boolean equals(Object obj) {
|
67 | 69 | return true;
|
68 | 70 | }
|
69 | 71 |
|
70 |
| - if(!(obj instanceof MojoExecutionMappingRequirement)) { |
71 |
| - return false; |
72 |
| - } |
73 |
| - |
74 |
| - MojoExecutionMappingRequirement other = (MojoExecutionMappingRequirement) obj; |
75 |
| - |
76 |
| - return execution.equals(other.execution); |
77 |
| - |
| 72 | + return obj instanceof MojoExecutionMappingRequirement other && execution.equals(other.execution); |
78 | 73 | }
|
79 | 74 |
|
80 | 75 | /**
|
@@ -118,13 +113,8 @@ public boolean equals(Object obj) {
|
118 | 113 | return true;
|
119 | 114 | }
|
120 | 115 |
|
121 |
| - if(!(obj instanceof ProjectConfiguratorMappingRequirement)) { |
122 |
| - return false; |
123 |
| - } |
124 |
| - |
125 |
| - ProjectConfiguratorMappingRequirement other = (ProjectConfiguratorMappingRequirement) obj; |
126 |
| - |
127 |
| - return configuratorId.equals(other.configuratorId) && execution.equals(other.execution); |
| 116 | + return obj instanceof ProjectConfiguratorMappingRequirement other && configuratorId.equals(other.configuratorId) |
| 117 | + && execution.equals(other.execution); |
128 | 118 | }
|
129 | 119 |
|
130 | 120 | public MojoExecutionKey getExecution() {
|
@@ -212,39 +202,31 @@ public boolean equals(Object obj) {
|
212 | 202 | if(this == obj) {
|
213 | 203 | return true;
|
214 | 204 | }
|
215 |
| - if(!(obj instanceof MojoExecutionMappingConfiguration)) { |
216 |
| - return false; |
217 |
| - } |
218 |
| - MojoExecutionMappingConfiguration other = (MojoExecutionMappingConfiguration) obj; |
219 |
| - |
220 |
| - if(!execution.equals(other.execution)) { |
221 |
| - return false; |
222 |
| - } |
223 |
| - |
224 |
| - if(mapping == null) { |
225 |
| - return other.mapping == null; |
226 |
| - } |
227 |
| - |
228 |
| - if(other.mapping == null) { |
229 |
| - return false; |
230 |
| - } |
| 205 | + if(obj instanceof MojoExecutionMappingConfiguration other) { |
| 206 | + if(!execution.equals(other.execution)) { |
| 207 | + return false; |
| 208 | + } |
231 | 209 |
|
232 |
| - if(mapping.getAction() != other.mapping.getAction()) { |
233 |
| - return false; |
234 |
| - } |
| 210 | + if(mapping == null) { |
| 211 | + return other.mapping == null; |
| 212 | + } |
235 | 213 |
|
236 |
| - if(mapping.getAction() == PluginExecutionAction.configurator) { |
237 |
| - String configuratorId = LifecycleMappingFactory.getProjectConfiguratorId(mapping); |
238 |
| - String otherConfiguratorId = LifecycleMappingFactory.getProjectConfiguratorId(other.mapping); |
239 |
| - if(!eq(configuratorId, otherConfiguratorId)) { |
| 214 | + if(other.mapping == null) { |
240 | 215 | return false;
|
241 | 216 | }
|
242 |
| - } |
243 | 217 |
|
244 |
| - return true; |
245 |
| - } |
| 218 | + if(mapping.getAction() != other.mapping.getAction()) { |
| 219 | + return false; |
| 220 | + } |
246 | 221 |
|
247 |
| - private static <T> boolean eq(T a, T b) { |
248 |
| - return a != null ? a.equals(b) : b == null; |
| 222 | + if(mapping.getAction() == PluginExecutionAction.configurator) { |
| 223 | + String configuratorId = LifecycleMappingFactory.getProjectConfiguratorId(mapping); |
| 224 | + String otherConfiguratorId = LifecycleMappingFactory.getProjectConfiguratorId(other.mapping); |
| 225 | + if(!Objects.equals(configuratorId, otherConfiguratorId)) { |
| 226 | + return false; |
| 227 | + } |
| 228 | + } |
| 229 | + } |
| 230 | + return false; |
249 | 231 | }
|
250 | 232 | }
|
0 commit comments