AggregationPipelineQueryNode extends ExternalSet { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o instanceof AggregationPipelineQueryNode) { final AggregationPipelineQueryNode other = (AggregationPipelineQueryNode) o; if (this.collection.equals(other.collection) && this.assuredBindingNames.equals(other.assuredBindingNames) && this.bindingNames.equals(other.bindingNames) && this.varToOriginalName.equals(other.varToOriginalName) && this.pipeline.size() == other.pipeline.size()) { for (int i = 0; i < this.pipeline.size(); i++) { final Bson doc1 = this.pipeline.get(i); final Bson doc2 = other.pipeline.get(i); if (!doc1.toString().equals(doc2.toString())) { return false; } } return true; } } return false; } AggregationPipelineQueryNode(final MongoCollection<Document> collection, final StatementPattern baseSP);   AggregationPipelineQueryNode(final MongoCollection<Document> collection,
            final List<Bson> pipeline, final Set<String> assuredBindingNames,
            final Set<String> bindingNames, final BiMap<String, String> varToOriginalName); @Override boolean equals(final Object o); @Override int hashCode(); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final BindingSet bindings); @Override Set<String> getAssuredBindingNames(); @Override Set<String> getBindingNames(); @Override AggregationPipelineQueryNode clone(); @Override String getSignature(); boolean joinWith(final StatementPattern sp); boolean project(final Iterable<ProjectionElemList> projections); boolean extend(final Iterable<ExtensionElem> extensionElements); boolean filter(final ValueExpr condition); boolean distinct(); void requireSourceDerivationDepth(final int requiredLevel); void requireSourceTimestamp(final long t); List<Bson> getTriplePipeline(final long timestamp, final boolean requireNew);  }
@Test public void testEquals() { final AggregationPipelineQueryNode node1 = new AggregationPipelineQueryNode( collection, new LinkedList<>(), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), HashBiMap.create()); final AggregationPipelineQueryNode node2 = new AggregationPipelineQueryNode( collection, new LinkedList<>(), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), HashBiMap.create()); Assert.assertEquals(node1, node2); Assert.assertEquals(node1.hashCode(), node2.hashCode()); final AggregationPipelineQueryNode diff1 = new AggregationPipelineQueryNode( collection, new LinkedList<>(), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y"), HashBiMap.create()); final AggregationPipelineQueryNode diff2 = new AggregationPipelineQueryNode( collection, Arrays.asList(new Document()), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), HashBiMap.create()); HashBiMap<String, String> varMapping = HashBiMap.create(); varMapping.put("field-x", "x"); final AggregationPipelineQueryNode diff3 = new AggregationPipelineQueryNode( collection, Arrays.asList(new Document()), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), varMapping); Assert.assertNotEquals(diff1, node1); Assert.assertNotEquals(diff2, node1); Assert.assertNotEquals(diff3, node1); node1.joinWith(new StatementPattern(new Var("x"), constant(TAKES), new Var("c"))); node2.joinWith(new StatementPattern(new Var("x"), constant(TAKES), new Var("c"))); Assert.assertEquals(node1, node2); node2.joinWith(new StatementPattern(new Var("x"), constant(TAKES), new Var("c"))); Assert.assertNotEquals(node1, node2); }