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

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

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

import io.github.kiryu1223.drink.config.Config;
import io.github.kiryu1223.drink.core.expression.SqlExpression;

import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public abstract class BaseSqlExtension
{
    public abstract SqlExpression parse(Config config, Method sqlFunc, List args);

    private static final Map, BaseSqlExtension> sqlExtensionCache = new ConcurrentHashMap<>();

    public static BaseSqlExtension getCache(Class c)
    {
        BaseSqlExtension baseSqlExtension = sqlExtensionCache.get(c);
        if (baseSqlExtension == null)
        {
            try
            {
                baseSqlExtension = c.newInstance();
                sqlExtensionCache.put(c, baseSqlExtension);
            }
            catch (InstantiationException | IllegalAccessException e)
            {
                throw new RuntimeException(e);
            }
        }
        return baseSqlExtension;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy