### Question:
CategoryToPieDataset extends AbstractDataset implements PieDataset, DatasetChangeListener { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; } CategoryToPieDataset(CategoryDataset source,
                                TableOrder extract,
                                int index); CategoryDataset getUnderlyingDataset(); TableOrder getExtractType(); int getExtractIndex(); @Override int getItemCount(); @Override Number getValue(int item); @Override Comparable getKey(int index); @Override int getIndex(Comparable key); @Override List<Comparable> getKeys(); @Override Number getValue(Comparable key); @Override void datasetChanged(DatasetChangeEvent event); @Override boolean equals(Object obj);  }### Answer:
@Test public void testEquals() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_COLUMN, 1); DefaultPieDataset d2 = new DefaultPieDataset(); d2.setValue("R1", 2.2); assertEquals(d1, d2); }