private static <T> T cloneArray(final T array) throws Exception { final Class<?> elementClass = array.getClass().getComponentType(); final int length = Array.getLength(array); @SuppressWarnings("unchecked") final T newArray = (T) Array.newInstance(elementClass, length); for (int i = 0; i < length; i++) { Array.set(newArray, i, doClone(Array.get(array, i))); } return newArray; }
private static <K, V> Map<K, V> cloneMap(final Map<K, V> map) throws Exception { @SuppressWarnings("unchecked") final Map<K, V> newMap = newMap(map.getClass()); for (final Entry<K, V> entry : map.entrySet()) { final K clonedKey = doClone(entry.getKey()); final V clonedValue = doClone(entry.getValue()); newMap.put(clonedKey, clonedValue); } return newMap; }
private static <T> T cloneArray(final T array) throws Exception { final Class<?> elementClass = array.getClass().getComponentType(); final int length = Array.getLength(array); @SuppressWarnings("unchecked") final T newArray = (T) Array.newInstance(elementClass, length); for (int i = 0; i < length; i++) { Array.set(newArray, i, doClone(Array.get(array, i))); } return newArray; }
private static <K, V> Map<K, V> cloneMap(final Map<K, V> map) throws Exception { @SuppressWarnings("unchecked") final Map<K, V> newMap = newMap(map.getClass()); for (final Entry<K, V> entry : map.entrySet()) { final K clonedKey = doClone(entry.getKey()); final V clonedValue = doClone(entry.getValue()); newMap.put(clonedKey, clonedValue); } return newMap; }
private static <T> Collection<T> cloneCollection(final Collection<T> collection) throws Exception { @SuppressWarnings("unchecked") final Collection<T> newCollection = newCollection(collection.getClass()); for (final T item : collection) { newCollection.add(doClone(item)); } return newCollection; }
private static <T> Collection<T> cloneCollection(final Collection<T> collection) throws Exception { @SuppressWarnings("unchecked") final Collection<T> newCollection = newCollection(collection.getClass()); for (final T item : collection) { newCollection.add(doClone(item)); } return newCollection; }
value = doClone(value); setter.invoke(clonedBean, new Object[] { value });
value = doClone(value); setter.invoke(clonedBean, new Object[] { value });