cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: Align class name with other value types.
Date Tue, 03 Oct 2017 11:19:42 GMT
Repository: cayenne
Updated Branches:
  refs/heads/STABLE-4.0 e88766ee6 -> 522d45811


Align class name with other value types.


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/522d4581
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/522d4581
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/522d4581

Branch: refs/heads/STABLE-4.0
Commit: 522d458119985be7b55b85635a71d6589b333c39
Parents: e88766e
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Tue Oct 3 14:19:34 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Tue Oct 3 14:19:34 2017 +0300

----------------------------------------------------------------------
 .../cayenne/access/types/CharacterType.java     | 60 --------------------
 .../access/types/CharacterValueType.java        | 60 ++++++++++++++++++++
 .../configuration/server/ServerModule.java      |  4 +-
 .../unit/di/server/ServerCaseModule.java        |  4 +-
 4 files changed, 65 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/522d4581/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterType.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterType.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterType.java
deleted file mode 100644
index dcc1c98..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterType.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.access.types;
-
-/**
- * This is char and Character type mapped to zero or one char String.
- * @since 4.0
- */
-public class CharacterType implements ValueObjectType<Character, String> {
-    @Override
-    public Class<String> getTargetType() {
-        return String.class;
-    }
-
-    @Override
-    public Class<Character> getValueType() {
-        return Character.class;
-    }
-
-    @Override
-    public Character toJavaObject(String value) {
-        if(value == null) {
-            return null;
-        }
-        if(value.isEmpty()) {
-            return 0;
-        }
-        if(value.length() > 1) {
-            throw new IllegalArgumentException("Only one char String can be used, " + value
+ " used");
-        }
-        return value.charAt(0);
-    }
-
-    @Override
-    public String fromJavaObject(Character object) {
-        return String.valueOf(object);
-    }
-
-    @Override
-    public String toCacheKey(Character object) {
-        return String.valueOf(object);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/522d4581/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterValueType.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterValueType.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterValueType.java
new file mode 100644
index 0000000..ce62ad6
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/types/CharacterValueType.java
@@ -0,0 +1,60 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access.types;
+
+/**
+ * This is char and Character type mapped to zero or one char String.
+ * @since 4.0
+ */
+public class CharacterValueType implements ValueObjectType<Character, String> {
+    @Override
+    public Class<String> getTargetType() {
+        return String.class;
+    }
+
+    @Override
+    public Class<Character> getValueType() {
+        return Character.class;
+    }
+
+    @Override
+    public Character toJavaObject(String value) {
+        if(value == null) {
+            return null;
+        }
+        if(value.isEmpty()) {
+            return 0;
+        }
+        if(value.length() > 1) {
+            throw new IllegalArgumentException("Only one char String can be used, " + value
+ " used");
+        }
+        return value.charAt(0);
+    }
+
+    @Override
+    public String fromJavaObject(Character object) {
+        return String.valueOf(object);
+    }
+
+    @Override
+    public String toCacheKey(Character object) {
+        return String.valueOf(object);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/522d4581/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
index 723a24b..44b926a 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
@@ -41,7 +41,7 @@ import org.apache.cayenne.access.types.ByteArrayType;
 import org.apache.cayenne.access.types.ByteType;
 import org.apache.cayenne.access.types.CalendarType;
 import org.apache.cayenne.access.types.CharType;
-import org.apache.cayenne.access.types.CharacterType;
+import org.apache.cayenne.access.types.CharacterValueType;
 import org.apache.cayenne.access.types.DateType;
 import org.apache.cayenne.access.types.DefaultValueObjectTypeRegistry;
 import org.apache.cayenne.access.types.DoubleType;
@@ -330,7 +330,7 @@ public class ServerModule implements Module {
         contributeValueObjectTypes(binder)
                 .add(BigIntegerValueType.class)
                 .add(UUIDValueType.class)
-                .add(CharacterType.class);
+                .add(CharacterValueType.class);
         binder.bind(ValueObjectTypeRegistry.class).to(DefaultValueObjectTypeRegistry.class);
 
         // configure explicit configurations

http://git-wip-us.apache.org/repos/asf/cayenne/blob/522d4581/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
index ae4e01b..45fa376 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
@@ -31,6 +31,7 @@ import org.apache.cayenne.access.types.ByteArrayType;
 import org.apache.cayenne.access.types.ByteType;
 import org.apache.cayenne.access.types.CalendarType;
 import org.apache.cayenne.access.types.CharType;
+import org.apache.cayenne.access.types.CharacterValueType;
 import org.apache.cayenne.access.types.DateType;
 import org.apache.cayenne.access.types.DefaultValueObjectTypeRegistry;
 import org.apache.cayenne.access.types.DoubleType;
@@ -167,7 +168,8 @@ public class ServerCaseModule implements Module {
         ServerModule.contributeTypeFactories(binder);
         ServerModule.contributeValueObjectTypes(binder)
                 .add(BigIntegerValueType.class)
-                .add(UUIDValueType.class);
+                .add(UUIDValueType.class)
+                .add(CharacterValueType.class);
         binder.bind(ValueObjectTypeRegistry.class).to(DefaultValueObjectTypeRegistry.class);
 
         binder.bind(SchemaBuilder.class).to(SchemaBuilder.class);


Mime
View raw message