@Test public void testSetObject() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); assertEquals("Obj1", data.getObject("R1", "C1")); assertEquals("Obj2", data.getObject("R2", "C2")); assertNull(data.getObject("R1", "C2")); assertNull(data.getObject("R2", "C1")); data.setObject("ABC", "R2", "C2"); assertEquals("ABC", data.getObject("R2", "C2")); try { data.setObject("X", null, "C1"); fail("Should have thrown IllegalArgumentException on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'rowKey' argument.", e.getMessage()); } try { data.setObject("X", "R1", null); fail("Should have thrown IllegalArgumentException on duplicate key"); } catch (IllegalArgumentException e) { assertEquals("Null 'columnKey' argument.", e.getMessage()); } }
public void setObject(Object object, Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } KeyedObjects row; int rowIndex = this.rowKeys.indexOf(rowKey); if (rowIndex >= 0) { row = this.rows.get(rowIndex); } else { this.rowKeys.add(rowKey); row = new KeyedObjects(); this.rows.add(row); } row.setObject(columnKey, object); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } }
KeyedObjects2D implements Cloneable, Serializable { public void setObject(Object object, Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } KeyedObjects row; int rowIndex = this.rowKeys.indexOf(rowKey); if (rowIndex >= 0) { row = this.rows.get(rowIndex); } else { this.rowKeys.add(rowKey); row = new KeyedObjects(); this.rows.add(row); } row.setObject(columnKey, object); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } } }
KeyedObjects2D implements Cloneable, Serializable { public void setObject(Object object, Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } KeyedObjects row; int rowIndex = this.rowKeys.indexOf(rowKey); if (rowIndex >= 0) { row = this.rows.get(rowIndex); } else { this.rowKeys.add(rowKey); row = new KeyedObjects(); this.rows.add(row); } row.setObject(columnKey, object); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } } KeyedObjects2D(); }
KeyedObjects2D implements Cloneable, Serializable { public void setObject(Object object, Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } KeyedObjects row; int rowIndex = this.rowKeys.indexOf(rowKey); if (rowIndex >= 0) { row = this.rows.get(rowIndex); } else { this.rowKeys.add(rowKey); row = new KeyedObjects(); this.rows.add(row); } row.setObject(columnKey, object); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } } KeyedObjects2D(); int getRowCount(); int getColumnCount(); Object getObject(int row, int column); Comparable getRowKey(int row); int getRowIndex(Comparable key); List<Comparable> getRowKeys(); Comparable getColumnKey(int column); int getColumnIndex(Comparable key); List<Comparable> getColumnKeys(); Object getObject(Comparable rowKey, Comparable columnKey); void addObject(Object object, Comparable rowKey,
            Comparable columnKey); void setObject(Object object, Comparable rowKey,
            Comparable columnKey); void removeObject(Comparable rowKey, Comparable columnKey); void removeRow(int rowIndex); void removeRow(Comparable rowKey); void removeColumn(int columnIndex); void removeColumn(Comparable columnKey); void clear(); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone(); }
KeyedObjects2D implements Cloneable, Serializable { public void setObject(Object object, Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } KeyedObjects row; int rowIndex = this.rowKeys.indexOf(rowKey); if (rowIndex >= 0) { row = this.rows.get(rowIndex); } else { this.rowKeys.add(rowKey); row = new KeyedObjects(); this.rows.add(row); } row.setObject(columnKey, object); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } } KeyedObjects2D(); int getRowCount(); int getColumnCount(); Object getObject(int row, int column); Comparable getRowKey(int row); int getRowIndex(Comparable key); List<Comparable> getRowKeys(); Comparable getColumnKey(int column); int getColumnIndex(Comparable key); List<Comparable> getColumnKeys(); Object getObject(Comparable rowKey, Comparable columnKey); void addObject(Object object, Comparable rowKey,
            Comparable columnKey); void setObject(Object object, Comparable rowKey,
            Comparable columnKey); void removeObject(Comparable rowKey, Comparable columnKey); void removeRow(int rowIndex); void removeRow(Comparable rowKey); void removeColumn(int columnIndex); void removeColumn(Comparable columnKey); void clear(); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone();  }