@Test public void testEquals() { DependencyPath path1 = new DependencyPath(null) .append(new Dependency(foo, "compile")) .append(new Dependency(bar, "compile")); DependencyPath path2 = new DependencyPath(null) .append(new Dependency(foo, "compile")) .append(new Dependency(bar, "compile")); DependencyPath path3 = new DependencyPath(null) .append(new Dependency(bar, "compile")) .append(new Dependency(foo, "compile")); DependencyPath path4 = new DependencyPath(null).append(new Dependency(foo, "compile")); new EqualsTester() .addEqualityGroup(path1, path2) .addEqualityGroup(path3) .addEqualityGroup(path4) .testEquals(); }
@Override public boolean equals(Object o) { if (!(o instanceof DependencyPath)) { return false; } DependencyPath other = (DependencyPath) o; if (!Objects.equals(other.root, root)) { return false; } if (other.path.size() != path.size()) { return false; } for (int i = 0; i < path.size(); i++) { Dependency thisNode = path.get(i); Dependency otherNode = other.path.get(i); if (!artifactsEqual(thisNode.getArtifact(), otherNode.getArtifact())) { return false; } if (!thisNode.getScope().equals(otherNode.getScope())) { return false; } if (thisNode.isOptional() != otherNode.isOptional()) { return false; } } return true; }
DependencyPath { @Override public boolean equals(Object o) { if (!(o instanceof DependencyPath)) { return false; } DependencyPath other = (DependencyPath) o; if (!Objects.equals(other.root, root)) { return false; } if (other.path.size() != path.size()) { return false; } for (int i = 0; i < path.size(); i++) { Dependency thisNode = path.get(i); Dependency otherNode = other.path.get(i); if (!artifactsEqual(thisNode.getArtifact(), otherNode.getArtifact())) { return false; } if (!thisNode.getScope().equals(otherNode.getScope())) { return false; } if (thisNode.isOptional() != otherNode.isOptional()) { return false; } } return true; } }
DependencyPath { @Override public boolean equals(Object o) { if (!(o instanceof DependencyPath)) { return false; } DependencyPath other = (DependencyPath) o; if (!Objects.equals(other.root, root)) { return false; } if (other.path.size() != path.size()) { return false; } for (int i = 0; i < path.size(); i++) { Dependency thisNode = path.get(i); Dependency otherNode = other.path.get(i); if (!artifactsEqual(thisNode.getArtifact(), otherNode.getArtifact())) { return false; } if (!thisNode.getScope().equals(otherNode.getScope())) { return false; } if (thisNode.isOptional() != otherNode.isOptional()) { return false; } } return true; } DependencyPath(@Nullable Artifact root); }
DependencyPath { @Override public boolean equals(Object o) { if (!(o instanceof DependencyPath)) { return false; } DependencyPath other = (DependencyPath) o; if (!Objects.equals(other.root, root)) { return false; } if (other.path.size() != path.size()) { return false; } for (int i = 0; i < path.size(); i++) { Dependency thisNode = path.get(i); Dependency otherNode = other.path.get(i); if (!artifactsEqual(thisNode.getArtifact(), otherNode.getArtifact())) { return false; } if (!thisNode.getScope().equals(otherNode.getScope())) { return false; } if (thisNode.isOptional() != otherNode.isOptional()) { return false; } } return true; } DependencyPath(@Nullable Artifact root); @VisibleForTesting DependencyPath append(Dependency dependency); DependencyPath concat(DependencyPath childPath); int size(); Artifact getLeaf(); ImmutableList<String> getArtifactKeys(); Artifact get(int i); Dependency getDependency(int i); Artifact findExclusion(String groupId, String artifactId); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
DependencyPath { @Override public boolean equals(Object o) { if (!(o instanceof DependencyPath)) { return false; } DependencyPath other = (DependencyPath) o; if (!Objects.equals(other.root, root)) { return false; } if (other.path.size() != path.size()) { return false; } for (int i = 0; i < path.size(); i++) { Dependency thisNode = path.get(i); Dependency otherNode = other.path.get(i); if (!artifactsEqual(thisNode.getArtifact(), otherNode.getArtifact())) { return false; } if (!thisNode.getScope().equals(otherNode.getScope())) { return false; } if (thisNode.isOptional() != otherNode.isOptional()) { return false; } } return true; } DependencyPath(@Nullable Artifact root); @VisibleForTesting DependencyPath append(Dependency dependency); DependencyPath concat(DependencyPath childPath); int size(); Artifact getLeaf(); ImmutableList<String> getArtifactKeys(); Artifact get(int i); Dependency getDependency(int i); Artifact findExclusion(String groupId, String artifactId); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }