Removed DefaultColumnNamingStrategy in favor of a factory method
authorkaspersorensen <i.am.kasper.sorensen@gmail.com>
Tue, 26 Apr 2016 19:08:47 +0000 (12:08 -0700)
committerkaspersorensen <i.am.kasper.sorensen@gmail.com>
Tue, 26 Apr 2016 19:08:47 +0000 (12:08 -0700)
core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java [moved from core/src/main/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategy.java with 62% similarity]
core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java [moved from core/src/main/java/org/apache/metamodel/schema/builder/DelegatingIntrinsicSwitchColumnNamingStrategy.java with 89% similarity]
core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java
csv/src/main/java/org/apache/metamodel/csv/CsvConfiguration.java
fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java

  */\r
 package org.apache.metamodel.schema.naming;\r
 \r
-import org.apache.metamodel.schema.builder.DelegatingIntrinsicSwitchColumnNamingStrategy;\r
-\r
 /**\r
- * The default (in most cases) {@link ColumnNamingStrategy} to use when no other\r
- * strategy is specified.\r
+ * Constructors and common utilities for {@link ColumnNamingStrategy} objects.\r
  */\r
-public class DefaultColumnNamingStrategy extends DelegatingIntrinsicSwitchColumnNamingStrategy {\r
+public class ColumnNamingStrategies {\r
 \r
-    private static final long serialVersionUID = 1L;\r
+    private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(\r
+            new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());\r
 \r
-    public DefaultColumnNamingStrategy() {\r
-        super(new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());\r
+    private ColumnNamingStrategies() {\r
     }\r
 \r
+    public static ColumnNamingStrategy defaultStrategy() {\r
+        return DEFAULT_STRATEGY;\r
+    }\r
 }\r
  * specific language governing permissions and limitations\r
  * under the License.\r
  */\r
-package org.apache.metamodel.schema.builder;\r
-\r
-import org.apache.metamodel.schema.naming.ColumnNamingContext;\r
-import org.apache.metamodel.schema.naming.ColumnNamingSession;\r
-import org.apache.metamodel.schema.naming.ColumnNamingStrategy;\r
+package org.apache.metamodel.schema.naming;\r
 \r
 /**\r
  * A {@link ColumnNamingStrategy} that switches between two other\r
index a293939..eb618c2 100644 (file)
  */
 package org.apache.metamodel.schema.naming;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
-import org.apache.metamodel.schema.naming.ColumnNamingContextImpl;
-import org.apache.metamodel.schema.naming.ColumnNamingSession;
-import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.junit.Test;
 
 public class DefaultColumnNamingStrategyTest {
 
-    private final DefaultColumnNamingStrategy namingStrategy = new DefaultColumnNamingStrategy();
+    private final ColumnNamingStrategy namingStrategy = ColumnNamingStrategies.defaultStrategy();
 
     @Test
     public void testDuplicateColumnNames() throws Exception {
index dd1c8ac..abcf2d4 100644 (file)
@@ -21,8 +21,8 @@ package org.apache.metamodel.csv;
 import java.io.Serializable;
 import java.util.List;
 
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
 import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -103,7 +103,7 @@ public final class CsvConfiguration extends BaseObject implements Serializable {
      */
     public ColumnNamingStrategy getColumnNamingStrategy() {
         if (columnNamingStrategy == null) {
-            return new DefaultColumnNamingStrategy();
+            return ColumnNamingStrategies.defaultStrategy();
         }
         return columnNamingStrategy;
     }
index bbdd0ad..6e9f0f1 100644 (file)
@@ -23,8 +23,8 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
 import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
-import org.apache.metamodel.schema.naming.DefaultColumnNamingStrategy;
 import org.apache.metamodel.util.BaseObject;
 import org.apache.metamodel.util.FileHelper;
 
@@ -100,7 +100,7 @@ public final class FixedWidthConfiguration extends BaseObject implements
         */
        public ColumnNamingStrategy getColumnNamingStrategy() {
            if (columnNamingStrategy == null) {
-               return new DefaultColumnNamingStrategy();
+               return ColumnNamingStrategies.defaultStrategy();
            }
         return columnNamingStrategy;
     }