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

de.jaggl.sqlbuilder.dialect.Dialects Maven / Gradle / Ivy

There is a newer version: 2.7.2
Show newest version
package de.jaggl.sqlbuilder.dialect;

import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;

import de.jaggl.sqlbuilder.domain.exceptions.UnknownDialectException;

/**
 * @author Martin Schumacher
 *
 * @since 2.0.0
 */
public final class Dialects
{
    private static final Map REGISTERED_DIALECTS = new HashMap<>();

    private Dialects()
    {
        // private constructor to hide the public one
    }

    static void register(Dialect dialect)
    {
        REGISTERED_DIALECTS.put(dialect.getName().toLowerCase(), dialect);
    }

    static void unregister(String name)
    {
        REGISTERED_DIALECTS.remove(name.toLowerCase());
    }

    static Dialect forName(String name)
    {
        Dialect dialect = REGISTERED_DIALECTS.get(name.toLowerCase());
        if (dialect == null)
        {
            throw new UnknownDialectException(MessageFormat.format("no dialect registered for name ''{0}''", name));
        }
        return dialect;
    }

    public static final Dialect MYSQL = MySqlDialect.getInstance();
    public static final Dialect SYBASE = SybaseDialect.getInstance();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy