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

cn.featherfly.common.lang.Instances Maven / Gradle / Ivy


package cn.featherfly.common.lang;

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

/**
 * 

* Instances *

* . * * @author zhongj */ public class Instances { private static final Map, Object> INSTANCES = new ConcurrentHashMap<>(); /** * Singleton. * * @param the generic type * @param type the type * @return the t */ public static final T singleton(Class type) { @SuppressWarnings("unchecked") T object = (T) INSTANCES.get(type); if (object == null) { object = ClassUtils.newInstance(type); INSTANCES.put(type, object); } return object; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy