mirror of https://github.com/apache/maven.git
[refactor] use utility method of Objects to simplify code (#284)
* [refactor] use utility method of Objects to simplify code * [refactor] use utility method of Objects to simplify code
This commit is contained in:
parent
3eb242c571
commit
d09bc7437f
|
@ -25,6 +25,7 @@
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
|
@ -593,11 +594,9 @@ public boolean equals( Object obj )
|
|||
VersionRange other = (VersionRange) obj;
|
||||
|
||||
boolean equals =
|
||||
recommendedVersion == other.recommendedVersion
|
||||
|| ( ( recommendedVersion != null ) && recommendedVersion.equals( other.recommendedVersion ) );
|
||||
Objects.equals(recommendedVersion, other.recommendedVersion);
|
||||
equals &=
|
||||
restrictions == other.restrictions
|
||||
|| ( ( restrictions != null ) && restrictions.equals( other.restrictions ) );
|
||||
Objects.equals(restrictions, other.restrictions);
|
||||
return equals;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
@ -69,7 +70,7 @@ public void omitForNearer( Artifact omitted, Artifact kept )
|
|||
String omittedVersion = omitted.getVersion();
|
||||
String keptVersion = kept.getVersion();
|
||||
|
||||
if ( omittedVersion != null ? !omittedVersion.equals( keptVersion ) : keptVersion != null )
|
||||
if (!Objects.equals(omittedVersion, keptVersion))
|
||||
{
|
||||
logger.debug( indent + omitted + " (removed - nearer found: " + keptVersion + ")" );
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
|
@ -353,7 +354,7 @@ public boolean equals( Object obj )
|
|||
|
||||
protected static <T> boolean eq( T s1, T s2 )
|
||||
{
|
||||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||
return Objects.equals(s1, s2);
|
||||
}
|
||||
|
||||
public Authentication getAuthentication()
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Filter to only retain objects in the given artifactScope or better.
|
||||
*
|
||||
|
@ -72,7 +74,7 @@ public boolean equals( Object obj )
|
|||
|
||||
private static <T> boolean equals( T str1, T str2 )
|
||||
{
|
||||
return str1 != null ? str1.equals( str2 ) : str2 == null;
|
||||
return Objects.equals(str1, str2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class CacheUtils
|
|||
@Deprecated
|
||||
public static <T> boolean eq( T s1, T s2 )
|
||||
{
|
||||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||
return Objects.equals(s1, s2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.maven.RepositoryUtils;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
|
@ -212,7 +213,7 @@ private static int hash( Object obj )
|
|||
|
||||
private static <T> boolean eq( T s1, T s2 )
|
||||
{
|
||||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||
return Objects.equals(s1, s2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.maven.RepositoryUtils;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
@ -1061,7 +1062,7 @@ else if ( !( other instanceof MavenProject ) )
|
|||
|
||||
private static <T> boolean eq( T s1, T s2 )
|
||||
{
|
||||
return ( s1 != null ) ? s1.equals( s2 ) : s2 == null;
|
||||
return Objects.equals(s1, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
@ -201,7 +202,7 @@ private static boolean repositoriesEquals( List<ArtifactRepository> r1, List<Art
|
|||
|
||||
private static <T> boolean eq( T s1, T s2 )
|
||||
{
|
||||
return s1 != null ? s1.equals( s2 ) : s2 == null;
|
||||
return Objects.equals(s1, s2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.maven.toolchain.model.ToolchainModel;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -137,7 +138,7 @@ public boolean equals( Object obj )
|
|||
|
||||
DefaultToolchain other = (DefaultToolchain) obj;
|
||||
|
||||
if ( type == null ? other.type != null : !type.equals( other.type ) )
|
||||
if (!Objects.equals(type, other.type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ public boolean equals( Object obj )
|
|||
Properties thisProvides = this.getModel().getProvides();
|
||||
Properties otherProvides = other.getModel().getProvides();
|
||||
|
||||
if ( thisProvides == null ? otherProvides != null : !thisProvides.equals( otherProvides ) )
|
||||
if (!Objects.equals(thisProvides, otherProvides))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue