maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact Artifact.java DefaultArtifact.java
Date Wed, 20 Apr 2005 16:49:25 GMT
brett       2005/04/20 09:49:25

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact
                        Artifact.java DefaultArtifact.java
  Log:
  artifact implements comparable
  
  Revision  Changes    Path
  1.12      +1 -0      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java
  
  Index: Artifact.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Artifact.java	29 Mar 2005 16:41:13 -0000	1.11
  +++ Artifact.java	20 Apr 2005 16:49:24 -0000	1.12
  @@ -28,6 +28,7 @@
    * @todo do we really need an interface here?
    */
   public interface Artifact
  +    extends Comparable
   {
       // TODO: into scope handler
       String SCOPE_COMPILE = "compile";
  
  
  
  1.22      +41 -1     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
  
  Index: DefaultArtifact.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultArtifact.java	29 Mar 2005 16:41:13 -0000	1.21
  +++ DefaultArtifact.java	20 Apr 2005 16:49:24 -0000	1.22
  @@ -249,4 +249,44 @@
           this.baseVersion = baseVersion;
       }
   
  +    public int compareTo( Object o )
  +    {
  +        Artifact a = (Artifact) o;
  +
  +        int result = groupId.compareTo( a.getGroupId() );
  +        if ( result == 0 )
  +        {
  +            result = artifactId.compareTo( a.getArtifactId() );
  +            if ( result == 0 )
  +            {
  +                result = type.compareTo( a.getType() );
  +                if ( result == 0 )
  +                {
  +                    if ( classifier == null )
  +                    {
  +                        if ( a.getClassifier() != null )
  +                        {
  +                            result = 1;
  +                        }
  +                    }
  +                    else
  +                    {
  +                        if ( a.getClassifier() != null )
  +                        {
  +                            result = classifier.compareTo( a.getClassifier() );
  +                        }
  +                        else
  +                        {
  +                            result = -1;
  +                        }
  +                    }
  +                    if ( result == 0 )
  +                    {
  +                        result = version.compareTo( a.getVersion() );
  +                    }
  +                }
  +            }
  +        }
  +        return result;
  +    }
   }
  \ No newline at end of file
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Mime
View raw message