
org.gra4j.gazelle.structure.CheckerPool Maven / Gradle / Ivy
The newest version!
package org.gra4j.gazelle.structure;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* gazelle
* org.gra4j.gazelle.structure
*
* @author tom.long
*/
public abstract class CheckerPool implements Serializable {
final static Map pool = new ConcurrentHashMap<>();
public static Object getIfExist (Class targetClass) throws IllegalAccessException, InstantiationException {
Object checker = pool.get(targetClass);
if (null==checker) {
checker = targetClass.newInstance();
pool.putIfAbsent(targetClass, checker);
}
return checker;
}
public static Map getPool() {
return pool;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy