public <T> T deepCloneDontCloneInstances(final T o, final Object... dontCloneThese) { if (o == null) return null; if (!cloningEnabled) return o; if (dumpCloned != null) { dumpCloned.startCloning(o.getClass()); } final Map<Object, Object> clones = new IdentityHashMap<Object, Object>(16); for (final Object dc : dontCloneThese) { clones.put(dc, dc); } try { return cloneInternal(o, clones); } catch (final IllegalAccessException e) { throw new CloningException("error during cloning of " + o, e); } }
private <T> T cloneObject(T o, Map<Object, Object> clones, Class<T> clz) throws IllegalAccessException { final T newInstance = newInstance(clz); if (clones != null) { clones.put(o, newInstance); } final List<Field> fields = allFields(clz); for (final Field field : fields) { final int modifiers = field.getModifiers(); if (!Modifier.isStatic(modifiers)) { if (!(nullTransient && Modifier.isTransient(modifiers))) { // request by Jonathan : transient fields can be null-ed final Object fieldObject = field.get(o); final boolean shouldClone = (cloneSynthetics || !field.isSynthetic()) && (cloneAnonymousParent || !isAnonymousParent(field)); final Object fieldObjectClone = clones != null ? (shouldClone ? applyCloningStrategy(clones, o, fieldObject, field) : fieldObject) : fieldObject; field.set(newInstance, fieldObjectClone); if (dumpCloned != null && fieldObjectClone != fieldObject) { dumpCloned.cloning(field, o.getClass()); } } } } return newInstance; }
private <T> T cloneObject(T o, Map<Object, Object> clones, Class<T> clz) throws IllegalAccessException { final T newInstance = newInstance(clz); if (clones != null) { clones.put(o, newInstance); } final List<Field> fields = allFields(clz); for (final Field field : fields) { final int modifiers = field.getModifiers(); if (!Modifier.isStatic(modifiers)) { if (!(nullTransient && Modifier.isTransient(modifiers))) { // request by Jonathan : transient fields can be null-ed final Object fieldObject = field.get(o); final boolean shouldClone = (cloneSynthetics || !field.isSynthetic()) && (cloneAnonymousParent || !isAnonymousParent(field)); final Object fieldObjectClone = clones != null ? (shouldClone ? applyCloningStrategy(clones, o, fieldObject, field) : fieldObject) : fieldObject; field.set(newInstance, fieldObjectClone); if (dumpCloned != null && fieldObjectClone != fieldObject) { dumpCloned.cloning(field, o.getClass()); } } } } return newInstance; }
public <T> T deepCloneDontCloneInstances(final T o, final Object... dontCloneThese) { if (o == null) return null; if (!cloningEnabled) return o; if (dumpCloned != null) { dumpCloned.startCloning(o.getClass()); } final Map<Object, Object> clones = new IdentityHashMap<Object, Object>(16); for (final Object dc : dontCloneThese) { clones.put(dc, dc); } try { return cloneInternal(o, clones); } catch (final IllegalAccessException e) { throw new CloningException("error during cloning of " + o, e); } }
/** * deep clones "o". * * @param <T> the type of "o" * @param o the object to be deep-cloned * @return a deep-clone of "o". */ public <T> T deepClone(final T o) { if (o == null) return null; if (!cloningEnabled) return o; if (dumpCloned != null) { dumpCloned.startCloning(o.getClass()); } final Map<Object, Object> clones = new IdentityHashMap<Object, Object>(16); try { return cloneInternal(o, clones); } catch (final IllegalAccessException e) { throw new CloningException("error during cloning of " + o, e); } }
/** * deep clones "o". * * @param <T> the type of "o" * @param o the object to be deep-cloned * @return a deep-clone of "o". */ public <T> T deepClone(final T o) { if (o == null) return null; if (!cloningEnabled) return o; if (dumpCloned != null) { dumpCloned.startCloning(o.getClass()); } final Map<Object, Object> clones = new IdentityHashMap<Object, Object>(16); try { return cloneInternal(o, clones); } catch (final IllegalAccessException e) { throw new CloningException("error during cloning of " + o, e); } }
dumpCloned.startCloning(o.getClass());
dumpCloned.startCloning(o.getClass());