private Spatial duplicate() {
Spatial spat = null;
final Class<? extends Spatial> clazz = getClass();
try {
final SavableFactory ann = clazz.getAnnotation(SavableFactory.class);
if (ann == null) {
spat = clazz.newInstance();
} else {
spat = (Spatial) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null, (Object[]) null);
}
} catch (final InstantiationException e) {
logger.log(Level.SEVERE, "Could not access final constructor of class " + clazz.getCanonicalName(), e);
throw new RuntimeException(e);
} catch (final IllegalAccessException e) {