summaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-17 19:19:47 +0200
committerDavid Gageot <david@gageot.net>2012-07-17 19:30:15 +0200
commiteea23a747c664c691547be6ad9691218cb5647e4 (patch)
tree8d4cc4409df627765284927f50d016fa586bcedc /sonar-core
parentf47a41472402354bcbea8d4699b78463b42ae254 (diff)
downloadsonarqube-eea23a747c664c691547be6ad9691218cb5647e4.tar.gz
sonarqube-eea23a747c664c691547be6ad9691218cb5647e4.zip
Remove some duplication
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java47
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java14
6 files changed, 62 insertions, 55 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java
new file mode 100644
index 00000000000..6c0eec35fd1
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java
@@ -0,0 +1,47 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.persistence.dialect;
+
+/**
+ * @since 3.2
+ */
+abstract class AbstractDialect implements Dialect {
+ private final String id;
+ private final String activeRecordDialectCode;
+ private final String activeRecordJdbcAdapter;
+
+ protected AbstractDialect(String id, String activeRecordDialectCode, String activeRecordJdbcAdapter) {
+ this.id = id;
+ this.activeRecordDialectCode = activeRecordDialectCode;
+ this.activeRecordJdbcAdapter = activeRecordJdbcAdapter;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getActiveRecordDialectCode() {
+ return activeRecordDialectCode;
+ }
+
+ public String getActiveRecordJdbcAdapter() {
+ return activeRecordJdbcAdapter;
+ }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
index fd761f82d24..0872be0776b 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
@@ -25,20 +25,12 @@ import org.hibernate.dialect.H2Dialect;
/**
* @since 1.12
*/
-public class H2 implements Dialect {
+public class H2 extends AbstractDialect {
public static final String ID = "h2";
- public String getId() {
- return ID;
- }
-
- public String getActiveRecordDialectCode() {
- return "h2";
- }
-
- public String getActiveRecordJdbcAdapter() {
- return "jdbc";
+ public H2() {
+ super(ID, "h2", "jdbc");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
index 0b0e944f489..7213d59304b 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
@@ -25,20 +25,12 @@ import org.sonar.api.database.DatabaseProperties;
import java.sql.Types;
-public class MsSql implements Dialect {
+public class MsSql extends AbstractDialect {
public static final String ID = "mssql";
- public String getId() {
- return ID;
- }
-
- public String getActiveRecordDialectCode() {
- return "sqlserver";
- }
-
- public String getActiveRecordJdbcAdapter() {
- return "jdbc";
+ public MsSql() {
+ super(ID, "sqlserver", "jdbc");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
index 94f8dc8cf1a..f3e20eacc66 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
@@ -28,20 +28,12 @@ import java.sql.Types;
/**
* @since 1.12
*/
-public class MySql implements Dialect {
+public class MySql extends AbstractDialect {
public static final String ID = "mysql";
- public String getId() {
- return ID;
- }
-
- public String getActiveRecordDialectCode() {
- return "mysql";
- }
-
- public String getActiveRecordJdbcAdapter() {
- return "jdbc";
+ public MySql() {
+ super(ID, "mysql", "jdbc");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
index a9f235a23e8..b8c6466d707 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
@@ -28,20 +28,12 @@ import java.sql.Types;
/**
* @since 1.12
*/
-public class Oracle implements Dialect {
+public class Oracle extends AbstractDialect {
public static final String ID = "oracle";
- public String getId() {
- return ID;
- }
-
- public String getActiveRecordDialectCode() {
- return "oracle";
- }
-
- public String getActiveRecordJdbcAdapter() {
- return "oracle_enhanced";
+ public Oracle() {
+ super(ID, "oracle", "oracle");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java
index 07d5ddd48ed..9460aa9051a 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java
@@ -27,20 +27,12 @@ import java.sql.Types;
/**
* @since 1.12
*/
-public class PostgreSql implements Dialect {
+public class PostgreSql extends AbstractDialect {
public static final String ID = "postgresql";
- public String getId() {
- return ID;
- }
-
- public String getActiveRecordDialectCode() {
- return "postgre";
- }
-
- public String getActiveRecordJdbcAdapter() {
- return "jdbc";
+ public PostgreSql() {
+ super(ID, "postgre", "jdbc");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {