psiroky commented on code in PR #173:
URL:
https://github.com/apache/maven-compiler-plugin/pull/173#discussion_r1090427466
##########
src/main/java/org/apache/maven/plugin/compiler/DependencyCoordinate.java:
##########
@@ -107,71 +123,17 @@ public boolean equals( Object obj )
{
return true;
}
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
+ if ( obj == null || getClass() != obj.getClass() )
{
return false;
}
DependencyCoordinate other = (DependencyCoordinate) obj;
- if ( artifactId == null )
- {
- if ( other.artifactId != null )
- {
- return false;
- }
- }
- else if ( !artifactId.equals( other.artifactId ) )
- {
- return false;
- }
- if ( classifier == null )
- {
- if ( other.classifier != null )
- {
- return false;
- }
- }
- else if ( !classifier.equals( other.classifier ) )
- {
- return false;
- }
- if ( groupId == null )
- {
- if ( other.groupId != null )
- {
- return false;
- }
- }
- else if ( !groupId.equals( other.groupId ) )
- {
- return false;
- }
- if ( type == null )
- {
- if ( other.type != null )
- {
- return false;
- }
- }
- else if ( !type.equals( other.type ) )
- {
- return false;
- }
- if ( version == null )
- {
- if ( other.version != null )
- {
- return false;
- }
- }
- else if ( !version.equals( other.version ) )
- {
- return false;
- }
- return true;
Review Comment:
I took the liberty of cleaning-up this monster of `equals()` method. The
only difference is that the order of fields that are being compared (e.g.
previously it started with `artifactId` and now I moved that to `groupId`). I
assume the idea behind this was some sort of optimization (e.g. `artifactId`
potentially differs more often than `groupId`) ,but I am not really sure that's
worth it. If anyone feels strongly about this, I can of course revert to the
previous "state" - the change would be trivial.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]