private AbstractSimon replaceUnknownSimon(AbstractSimon simon, Class<? extends AbstractSimon> simonClass) {
		AbstractSimon newSimon = instantiateSimon(simon.getName(), simonClass);
		newSimon.enabled = simon.enabled;

		// fixes parent link and parent's children list
		((AbstractSimon) simon.getParent()).replaceChild(simon, newSimon);

		// fixes children list and all children's parent link
		for (Simon child : simon.getChildren()) {
			newSimon.addChild((AbstractSimon) child);
			((AbstractSimon) child).setParent(newSimon);
		}

		allSimons.put(simon.getName(), newSimon);
		return newSimon;
	}
private AbstractSimon replaceUnknownSimon ( AbstractSimon simon , Class < ? extends AbstractSimon > simonClass ) { AbstractSimon newSimon = instantiateSimon ( simon . getName ( ) , simonClass ) ; newSimon . enabled = simon . enabled ; ( ( AbstractSimon ) simon . getParent ( ) ) . replaceChild ( simon , newSimon ) ; for ( Simon child : simon . getChildren ( ) ) { newSimon . addChild ( ( AbstractSimon ) child ) ; ( ( AbstractSimon ) child ) . setParent ( newSimon ) ; } allSimons . put ( simon . getName ( ) , newSimon ) ; return newSimon ; }
called from synchronized method