All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rits.cloning.FastClonerConcurrentHashMap Maven / Gradle / Ivy

Go to download

The cloning library is a small, open source (Apache licensed) Java library which deep-clones objects. The objects do not have to implement the Cloneable interface. Effectively, this library can clone ANY Java object. It can be used i.e. in cache implementations, if you don't want the cached object to be modified or whenever you want to create a deep copy of an object. This version contains a workaround for Java 8 Lambda Cloning Issue (not a proper solution).

The newest version!
package com.rits.cloning;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author kostantinos.kougios
 *
 * 18 Oct 2011
 */
public class FastClonerConcurrentHashMap implements IFastCloner
{
	@SuppressWarnings({ "unchecked", "rawtypes" })
    public Object clone(final Object t, final IDeepCloner cloner, final Map clones) {
		final ConcurrentHashMap m = (ConcurrentHashMap) t;
		final ConcurrentHashMap result = new ConcurrentHashMap();
		for (final Map.Entry e : m.entrySet()) {
			result.put(cloner.deepClone(e.getKey(), clones), cloner.deepClone(e.getValue(), clones));
		}
		return result;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy