LayoutArea implements Cloneable { @Override public LayoutArea clone() { try { LayoutArea clone = (LayoutArea) super.clone(); clone.bBox = bBox.clone(); return clone; } catch (CloneNotSupportedException e) { return null; } } LayoutArea(int pageNumber, Rectangle bBox); int getPageNumber(); Rectangle getBBox(); void setBBox(Rectangle bbox); @Override LayoutArea clone(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void cloneTest() { RootLayoutArea originalRootLayoutArea = new RootLayoutArea(1, new Rectangle(5, 10, 15, 20)); originalRootLayoutArea.emptyArea = false; LayoutArea cloneAsLayoutArea = ((LayoutArea) originalRootLayoutArea).clone(); RootLayoutArea cloneAsRootLayoutArea = (RootLayoutArea) originalRootLayoutArea.clone(); Assert.assertTrue((originalRootLayoutArea).getBBox() != cloneAsLayoutArea.getBBox()); Assert.assertEquals(RootLayoutArea.class, cloneAsRootLayoutArea.getClass()); Assert.assertEquals(RootLayoutArea.class, cloneAsLayoutArea.getClass()); Assert.assertFalse(((RootLayoutArea) cloneAsLayoutArea).isEmptyArea()); }