MagicWandModel implements Cloneable { @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @Override public MagicWandModel clone() { try { MagicWandModel clone = (MagicWandModel) super.clone(); clone.bandNames = new ArrayList<>(bandNames); clone.plusSpectra = new ArrayList<>(plusSpectra); clone.minusSpectra = new ArrayList<>(minusSpectra); clone.listeners = null; return clone; } catch (CloneNotSupportedException e) { throw new IllegalStateException(e); } } MagicWandModel(); void addListener(Listener listener); void removeListeners(); void fireModelChanged(boolean recomputeMask); @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @Override MagicWandModel clone(); void assign(MagicWandModel other); List<String> getBandNames(); void setBandNames(String... bandNames); void setBandNames(List<String> bandNames); PickMode getPickMode(); void setPickMode(PickMode pickMode); PixelTest getPixelTest(); void setPixelTest(PixelTest pixelTest); SpectrumTransform getSpectrumTransform(); void setSpectrumTransform(SpectrumTransform spectrumTransform); double getTolerance(); void setTolerance(double tolerance); double getMinTolerance(); void setMinTolerance(double minTolerance); double getMaxTolerance(); void setMaxTolerance(double maxTolerance); void setNormalize(boolean normalize); void setSpectralBandNames(Product product); static List<Band> getSpectralBands(Product product); @Override boolean equals(Object o); @Override int hashCode(); static MagicWandModel fromXml(String xml); String toXml();  }
@Test public void testClone() throws Exception { final MagicWandModel model = new MagicWandModel(); model.setBandNames("b1", "b2", "b3", "a1", "a2", "a3"); model.setTolerance(0.005); model.setMinTolerance(0.0); model.setMaxTolerance(0.01); model.setNormalize(true); model.setPickMode(MagicWandModel.PickMode.PLUS); model.addSpectrum(1, 2, 3, 4, 5, 6); model.addSpectrum(2, 3, 4, 5, 6, 7); model.setPickMode(MagicWandModel.PickMode.MINUS); model.addSpectrum(3, 4, 5, 6, 7, 8); model.addSpectrum(4, 5, 6, 7, 8, 9); final MagicWandModel modelCopy = model.clone(); assertEquals(model, modelCopy); }