@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Icon)) return false; Icon icon = (Icon) o; return index == icon.getIndex(); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Icon)) return false; Icon that = (Icon) o; return this.getIndex() == that.getIndex(); } }
@Override public G newGroup(Group group) { G result = newGroup(); result.setName(group.getName()); result.setIcon(this.newIcon(group.getIcon().getIndex())); return result; }
@Test public void testAddGroup() { Group g1 = database.getRootGroup().addGroup(database.newGroup("group1")); Assert.assertTrue (database.getRootGroup().getGroups().size() == 1); Assert.assertTrue (g1.getName().equals("group1")); Assert.assertTrue (g1.getGroups().size() == 0); Assert.assertTrue (g1.getEntries().size() == 0); Assert.assertTrue("root is not the parent of its child", g1.getParent().equals(database.getRootGroup())); Group g2 = database.newGroup(); assertEquals("", g2.getName()); Assert.assertNotNull(g2.getUuid()); assertEquals(0, g2.getIcon().getIndex()); assertEquals(0, g2.getGroups().size()); assertEquals(0, g2.getEntries().size()); // show that the list of groups is a copy database.getRootGroup().getGroups().clear(); Assert.assertTrue(database.getRootGroup().getGroups().size() == 1); Assert.assertTrue (g1.getEntries().size() == 0); }
@Override public E newEntry(Entry<?,?,?,?> entry) { E result = newEntry(); for (String propertyName: entry.getPropertyNames()) { try { // all implementations must support setting of STANDARD_PROPERTY_NAMES result.setProperty(propertyName, entry.getProperty(propertyName)); } catch (UnsupportedOperationException e) { // oh well, we tried } } try { for (String propertyName: (entry.getBinaryPropertyNames())) { try { // all implementations must support setting of STANDARD_PROPERTY_NAMES result.setBinaryProperty(propertyName, entry.getBinaryProperty(propertyName)); } catch (UnsupportedOperationException e) { // oh well, we tried } } } catch (UnsupportedOperationException e) { // never mind } result.setIcon(this.newIcon(entry.getIcon().getIndex())); // everything else should have been copied via properties return result; }