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

io.github.kiryu1223.drink.ext.SqlExtensionCache Maven / Gradle / Ivy

There is a newer version: 1.0.14
Show newest version
package io.github.kiryu1223.drink.ext;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SqlExtensionCache
{
    private static final Map, BaseSqlExtension> sqlExtensionCache = new ConcurrentHashMap<>();

    public static BaseSqlExtension get(Class c)
    {
        if (!sqlExtensionCache.containsKey(c))
        {
            try
            {
                sqlExtensionCache.put(c, c.getConstructor().newInstance());
            }
            catch (InstantiationException | IllegalAccessException | InvocationTargetException |
                   NoSuchMethodException e)
            {
                throw new RuntimeException(e);
            }
        }
        return sqlExtensionCache.get(c);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy