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

net.n2oapp.framework.engine.util.ClassHash Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.engine.util;

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

/**
 * Кэширует получаемые классы
 */
public class ClassHash {

    private static final Map classMap = new ConcurrentHashMap<>();

    /**
     * Берет класс из кэша
     *
     * @param className имя класса
     * @return класс
     */
    public static Class getClass(String className) {
        Class clazz = classMap.get(className);
        if (clazz == null) {
            try {
                clazz = Class.forName(className);
                classMap.put(className, clazz);
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException(e);
            }
        }
        return clazz;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy