org.mutabilitydetector.benchmarks.ImmutablePossiblyThreadsafeClass Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of MutabilityDetector Show documentation
Show all versions of MutabilityDetector Show documentation
Lightweight analysis tool for detecting mutability in Java
classes.
package org.mutabilitydetector.benchmarks;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
* From StackOverflow question.
* http://stackoverflow.com/questions/5635032/is-this-class-threadsafe
*/
public class ImmutablePossiblyThreadsafeClass {
private final Map map;
public ImmutablePossiblyThreadsafeClass(final Map map) {
this.map = new HashMap();
for (Entry entry : map.entrySet()) {
this.map.put(entry.getKey(), entry.getValue());
}
}
public V get(K key) {
return this.map.get(key);
}
}