@Test public void testCloning() throws CloneNotSupportedException { KeyedObject ko1 = new KeyedObject("Test", "Object"); KeyedObject ko2 = (KeyedObject) ko1.clone(); assertNotSame(ko1, ko2); assertSame(ko1.getClass(), ko2.getClass()); assertEquals(ko1, ko2); }
@Override public Object clone() throws CloneNotSupportedException { KeyedObject clone = (KeyedObject) super.clone(); if (this.object instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.object; clone.object = pc.clone(); } return clone; }
KeyedObject implements Cloneable, PublicCloneable, Serializable { @Override public Object clone() throws CloneNotSupportedException { KeyedObject clone = (KeyedObject) super.clone(); if (this.object instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.object; clone.object = pc.clone(); } return clone; } }
KeyedObject implements Cloneable, PublicCloneable, Serializable { @Override public Object clone() throws CloneNotSupportedException { KeyedObject clone = (KeyedObject) super.clone(); if (this.object instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.object; clone.object = pc.clone(); } return clone; } KeyedObject(Comparable key, Object object); }
KeyedObject implements Cloneable, PublicCloneable, Serializable { @Override public Object clone() throws CloneNotSupportedException { KeyedObject clone = (KeyedObject) super.clone(); if (this.object instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.object; clone.object = pc.clone(); } return clone; } KeyedObject(Comparable key, Object object); Comparable getKey(); Object getObject(); void setObject(Object object); @Override Object clone(); @Override boolean equals(Object obj); }
KeyedObject implements Cloneable, PublicCloneable, Serializable { @Override public Object clone() throws CloneNotSupportedException { KeyedObject clone = (KeyedObject) super.clone(); if (this.object instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.object; clone.object = pc.clone(); } return clone; } KeyedObject(Comparable key, Object object); Comparable getKey(); Object getObject(); void setObject(Object object); @Override Object clone(); @Override boolean equals(Object obj);  }