001/* 002 * Copyright 2015-2022 Transmogrify LLC, 2022-2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.pyranid; 018 019import org.jspecify.annotations.NonNull; 020 021/** 022 * Identifies different types of databases, which allows for special platform-specific handling. 023 * 024 * @author <a href="https://www.revetkn.com">Mark Allen</a> 025 * @since 1.0.0 026 */ 027public enum DatabaseType { 028 /** 029 * A database which requires no special handling. 030 */ 031 GENERIC, 032 /** 033 * A PostgreSQL database. 034 */ 035 POSTGRESQL, 036 /** 037 * An Oracle database. 038 */ 039 ORACLE, 040 /** 041 * A MySQL database. 042 * 043 * @since 4.3.0 044 */ 045 MYSQL, 046 /** 047 * A MariaDB database. 048 * 049 * @since 4.3.0 050 */ 051 MARIA_DB, 052 /** 053 * A SQLite database. 054 * 055 * @since 4.3.0 056 */ 057 SQLITE, 058 /** 059 * A Microsoft SQL Server database. 060 * 061 * @since 4.3.0 062 */ 063 SQL_SERVER, 064 /** 065 * A DuckDB database. 066 * 067 * @since 4.7.0 068 */ 069 DUCK_DB; 070 071 @NonNull 072 DatabaseDialect dialect() { 073 return switch (this) { 074 case POSTGRESQL -> PostgresDialect.INSTANCE; 075 case ORACLE -> OracleDialect.INSTANCE; 076 case MYSQL -> MySqlDialect.INSTANCE; 077 case MARIA_DB -> MariaDbDialect.INSTANCE; 078 case SQLITE -> SqliteDialect.INSTANCE; 079 case SQL_SERVER -> SqlServerDialect.INSTANCE; 080 case DUCK_DB -> DuckDbDialect.INSTANCE; 081 case GENERIC -> GenericDialect.INSTANCE; 082 }; 083 } 084 085}