com.android.ide.common.repository
Class GradleCoordinate

java.lang.Object
  extended by com.android.ide.common.repository.GradleCoordinate

public class GradleCoordinate
extends java.lang.Object

This class represents a maven coordinate and allows for comparison at any level.

This class does not directly implement Comparable; instead, you should use one of the specific Comparator constants based on what type of ordering you need.


Nested Class Summary
static class GradleCoordinate.ArtifactType
          List taken from http://maven.apache.org/pom.html#Maven_Coordinates
static class GradleCoordinate.ListComponent
          A list of components separated by dashes.
static class GradleCoordinate.NumberComponent
           
static class GradleCoordinate.PaddedNumberComponent
          Like NumberComponent, but used for numeric strings that have leading zeroes which we must preserve
static class GradleCoordinate.RevisionComponent
          A single component of a revision number: either a number, a string or a list of components separated by dashes.
static class GradleCoordinate.StringComponent
           
 
Field Summary
static java.util.Comparator<GradleCoordinate> COMPARE_PLUS_HIGHER
          Comparator which compares Gradle versions - and treats a + version as higher than a specific number.
static java.util.Comparator<GradleCoordinate> COMPARE_PLUS_LOWER
          Comparator which compares Gradle versions - and treats a + version as lower than a specific number in the same place.
static com.android.ide.common.repository.GradleCoordinate.PlusComponent PLUS_REV
           
static int PLUS_REV_VALUE
           
static java.lang.String PREVIEW_ID
           
 
Constructor Summary
GradleCoordinate(java.lang.String groupId, java.lang.String artifactId, GradleCoordinate.RevisionComponent... revisions)
          Constructor
GradleCoordinate(java.lang.String groupId, java.lang.String artifactId, int... revisions)
          Constructor
GradleCoordinate(java.lang.String groupId, java.lang.String artifactId, java.util.List<GradleCoordinate.RevisionComponent> revisions, GradleCoordinate.ArtifactType type)
          Constructor
 
Method Summary
 boolean acceptsGreaterRevisions()
           
 boolean equals(java.lang.Object o)
           
 java.lang.String getArtifactId()
           
 GradleCoordinate.ArtifactType getArtifactType()
           
 java.lang.String getGroupId()
           
 java.lang.String getId()
           
 int getMajorVersion()
          Returns the major version (X in X.2.3), which can be PLUS_REV, or Integer.MIN_VALUE if it is not available
 int getMicroVersion()
          Returns the major version (X in 1.2.X), which can be PLUS_REV, or Integer.MIN_VALUE if it is not available
 int getMinorVersion()
          Returns the minor version (X in 1.X.3), which can be PLUS_REV, or Integer.MIN_VALUE if it is not available
 java.lang.String getRevision()
           
 GradleCoordinate.ArtifactType getType()
           
 int hashCode()
           
 boolean isPreview()
           
 boolean isSameArtifact(GradleCoordinate o)
          Returns true if and only if the given coordinate refers to the same group and artifact.
static GradleCoordinate parseCoordinateString(java.lang.String coordinateString)
          Create a GradleCoordinate from a string of the form groupId:artifactId:MajorRevision.MinorRevision.(MicroRevision|+)
static java.util.List<GradleCoordinate.RevisionComponent> parseRevisionNumber(java.lang.String revision)
           
static GradleCoordinate parseVersionOnly(java.lang.String revision)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PREVIEW_ID

public static final java.lang.String PREVIEW_ID
See Also:
Constant Field Values

PLUS_REV

public static final com.android.ide.common.repository.GradleCoordinate.PlusComponent PLUS_REV

PLUS_REV_VALUE

public static final int PLUS_REV_VALUE
See Also:
Constant Field Values

COMPARE_PLUS_LOWER

public static final java.util.Comparator<GradleCoordinate> COMPARE_PLUS_LOWER
Comparator which compares Gradle versions - and treats a + version as lower than a specific number in the same place. This is typically useful when trying to for example order coordinates by "most specific".


COMPARE_PLUS_HIGHER

public static final java.util.Comparator<GradleCoordinate> COMPARE_PLUS_HIGHER
Comparator which compares Gradle versions - and treats a + version as higher than a specific number. This is typically useful when seeing if a dependency is met, e.g. if you require version 0.7.3, comparing it with 0.7.+ would consider 0.7.+ higher and therefore satisfying the version requirement.

Constructor Detail

GradleCoordinate

public GradleCoordinate(@NonNull
                        java.lang.String groupId,
                        @NonNull
                        java.lang.String artifactId,
                        @NonNull
                        GradleCoordinate.RevisionComponent... revisions)
Constructor


GradleCoordinate

public GradleCoordinate(@NonNull
                        java.lang.String groupId,
                        @NonNull
                        java.lang.String artifactId,
                        @NonNull
                        int... revisions)
Constructor


GradleCoordinate

public GradleCoordinate(@NonNull
                        java.lang.String groupId,
                        @NonNull
                        java.lang.String artifactId,
                        @NonNull
                        java.util.List<GradleCoordinate.RevisionComponent> revisions,
                        @Nullable
                        GradleCoordinate.ArtifactType type)
Constructor

Method Detail

parseCoordinateString

@Nullable
public static GradleCoordinate parseCoordinateString(@NonNull
                                                              java.lang.String coordinateString)
Create a GradleCoordinate from a string of the form groupId:artifactId:MajorRevision.MinorRevision.(MicroRevision|+)

Parameters:
coordinateString - the string to parse
Returns:
a coordinate object or null if the given string was malformed.

parseVersionOnly

public static GradleCoordinate parseVersionOnly(@NonNull
                                                java.lang.String revision)

parseRevisionNumber

@NonNull
public static java.util.List<GradleCoordinate.RevisionComponent> parseRevisionNumber(@NonNull
                                                                                             java.lang.String revision)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getGroupId

@Nullable
public java.lang.String getGroupId()

getArtifactId

@Nullable
public java.lang.String getArtifactId()

getArtifactType

@Nullable
public GradleCoordinate.ArtifactType getArtifactType()

getId

@Nullable
public java.lang.String getId()

getType

@Nullable
public GradleCoordinate.ArtifactType getType()

acceptsGreaterRevisions

public boolean acceptsGreaterRevisions()

getRevision

@NonNull
public java.lang.String getRevision()

isPreview

public boolean isPreview()

getMajorVersion

public int getMajorVersion()
Returns the major version (X in X.2.3), which can be PLUS_REV, or Integer.MIN_VALUE if it is not available


getMinorVersion

public int getMinorVersion()
Returns the minor version (X in 1.X.3), which can be PLUS_REV, or Integer.MIN_VALUE if it is not available


getMicroVersion

public int getMicroVersion()
Returns the major version (X in 1.2.X), which can be PLUS_REV, or Integer.MIN_VALUE if it is not available


isSameArtifact

public boolean isSameArtifact(@NonNull
                              GradleCoordinate o)
Returns true if and only if the given coordinate refers to the same group and artifact.

Parameters:
o - the coordinate to compare with
Returns:
true iff the other group and artifact match the group and artifact of this coordinate.

equals

public boolean equals(@NonNull
                      java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object