]> source.dussan.org Git - sonarqube.git/commitdiff
Remove some duplication
authorDavid Gageot <david@gageot.net>
Tue, 17 Jul 2012 17:19:47 +0000 (19:19 +0200)
committerDavid Gageot <david@gageot.net>
Tue, 17 Jul 2012 17:30:15 +0000 (19:30 +0200)
sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java

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 (file)
index 0000000..6c0eec3
--- /dev/null
@@ -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;
+  }
+}
index fd761f82d244fcfc00e3c9621b0f468d3412b2e7..0872be0776b708a0f8f99f4cc2e438eec868817a 100644 (file)
@@ -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() {
index 0b0e944f489bccf6a0b9db336735b6fc67269402..7213d59304bb5d68025c493c4c8091a648a74b44 100644 (file)
@@ -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() {
index 94f8dc8cf1ac2cafd695e3cfeb2784947eb3ed5c..f3e20eacc66f10f2129ee76ab6833aee5dbbd6ae 100644 (file)
@@ -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() {
index a9f235a23e85b658b451b900b3970f2bc96e7e61..b8c6466d707ad5e9f587b0e8622741a2f4912df1 100644 (file)
@@ -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() {
index 07d5ddd48edd8f55a94235b6cd4d6aee2c772aaf..9460aa9051a3239ea2ce7163f7d29b00f06f3d6c 100644 (file)
@@ -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() {