GradleCoordinate { public boolean matches(@NonNull GradleCoordinate pattern) { if (!isSameArtifact(pattern)) { return false; } Iterator<RevisionComponent> thisRev = mRevisions.iterator(); for (RevisionComponent thatRev : pattern.mRevisions) { if (thatRev instanceof PlusComponent) { return true; } if (!thisRev.hasNext() && thatRev.asInteger() != 0) { return false; } if (thisRev.hasNext() && !thatRev.equals(thisRev.next())) { return false; } } while (thisRev.hasNext()) { if (thisRev.next().asInteger() != 0) { return false; } } return true; } 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 testMatches() throws Exception { GradleCoordinate actual = new GradleCoordinate("a.b.c", "foo", 1, 2, 3); GradleCoordinate test = new GradleCoordinate("a.b.c", "foo", 1, 2, 3); assertTrue(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 1, 2, GradleCoordinate.PLUS_REV_VALUE); assertTrue(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 1, GradleCoordinate.PLUS_REV_VALUE); assertTrue(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", GradleCoordinate.PLUS_REV_VALUE); assertTrue(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 2); assertFalse(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 2, GradleCoordinate.PLUS_REV_VALUE); assertFalse(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 1, 2); assertFalse(actual.matches(test)); test = new GradleCoordinate("e.f.g", "foo", 1, GradleCoordinate.PLUS_REV_VALUE); assertFalse(actual.matches(test)); actual = new GradleCoordinate("a.b.c", "foo", 1); test = new GradleCoordinate("a.b.c", "foo", 1, GradleCoordinate.PLUS_REV_VALUE); assertTrue(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 1, 1, GradleCoordinate.PLUS_REV_VALUE); assertFalse(actual.matches(test)); test = new GradleCoordinate("a.b.c", "foo", 1, 0, GradleCoordinate.PLUS_REV_VALUE); assertTrue(actual.matches(test)); actual = new GradleCoordinate("a.b.c", "foo", 1, 0); test = new GradleCoordinate("a.b.c", "foo", 1); assertTrue(actual.matches(test)); }