GradleCoordinate { @Override public String toString() { String s = String.format(Locale.US, "%s:%s:%s", mGroupId, mArtifactId, getRevision()); if (mArtifactType != null) { s += "@" + mArtifactType.toString(); } return s; } GradleCoordinate(@NonNull String groupId, @NonNull String artifactId,
            @NonNull RevisionComponent... revisions);  GradleCoordinate(@NonNull String groupId, @NonNull String artifactId,
            @NonNull String revision);  GradleCoordinate(@NonNull String groupId, @NonNull String artifactId,
            @NonNull int... revisions);  GradleCoordinate(@NonNull String groupId, @NonNull String artifactId,
            @NonNull List<RevisionComponent> revisions, @Nullable ArtifactType type); @Nullable static GradleCoordinate parseCoordinateString(@NonNull String coordinateString); static GradleCoordinate parseVersionOnly(@NonNull String revision); @NonNull static List<RevisionComponent> parseRevisionNumber(@NonNull String revision); @Override String toString(); @Nullable String getGroupId(); @Nullable String getArtifactId(); @Nullable ArtifactType getArtifactType(); @Nullable String getId(); @Nullable ArtifactType getType(); boolean acceptsGreaterRevisions(); @NonNull String getRevision(); boolean isPreview(); int getMajorVersion(); int getMinorVersion(); int getMicroVersion(); boolean isSameArtifact(@NonNull GradleCoordinate o); boolean matches(@NonNull GradleCoordinate pattern); @Override boolean equals(@NonNull Object o); @Override int hashCode(); static final String PREVIEW_ID; static final PlusComponent PLUS_REV; static final int PLUS_REV_VALUE; static final Comparator<GradleCoordinate> COMPARE_PLUS_LOWER; static final Comparator<GradleCoordinate> COMPARE_PLUS_HIGHER; }
@Test public void testToString() throws Exception { String expected = "a.b.c:package:5.4.2"; String actual = new GradleCoordinate("a.b.c", "package", 5, 4, 2).toString(); assertEquals(expected, actual); expected = "a.b.c:package:5.4.+"; actual = new GradleCoordinate("a.b.c", "package", 5, 4, GradleCoordinate.PLUS_REV_VALUE) .toString(); assertEquals(expected, actual); expected = "a.b.c:package:5.+"; actual = new GradleCoordinate("a.b.c", "package", 5, GradleCoordinate.PLUS_REV_VALUE) .toString(); assertEquals(expected, actual); expected = "a.b.c:package:+"; actual = new GradleCoordinate("a.b.c", "package", GradleCoordinate.PLUS_REV).toString(); assertEquals(expected, actual); expected = "a.b.c:package:+@jar"; List<GradleCoordinate.RevisionComponent> revisionList = Lists.<GradleCoordinate.RevisionComponent>newArrayList(GradleCoordinate.PLUS_REV); actual = new GradleCoordinate("a.b.c", "package", revisionList, GradleCoordinate.ArtifactType.JAR).toString(); assertEquals(expected, actual); expected = "a.b.c:package:+@aar"; actual = new GradleCoordinate("a.b.c", "package", revisionList, GradleCoordinate.ArtifactType.AAR).toString(); assertEquals(expected, actual); expected = "com.google.maps.android:android-maps-utils:0.3"; actual = GradleCoordinate.parseCoordinateString(expected).toString(); assertEquals(expected, actual); expected = "a.b.c:package:v1.v2"; actual = new GradleCoordinate("a.b.c", "package", new GradleCoordinate.StringComponent("v1"), new GradleCoordinate.StringComponent("v2")).toString(); assertEquals(expected, actual); expected = "a.b.c:package:v1-1.17.0-rc-SNAPSHOT"; actual = new GradleCoordinate("a.b.c", "package", GradleCoordinate.ListComponent.of( new GradleCoordinate.StringComponent("v1"), new GradleCoordinate.NumberComponent(1)), new GradleCoordinate.NumberComponent(17), GradleCoordinate.ListComponent.of( new GradleCoordinate.NumberComponent(0), new GradleCoordinate.StringComponent("rc"), new GradleCoordinate.StringComponent("SNAPSHOT"))).toString(); assertEquals(expected, actual); }