cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [3/3] cayenne git commit: Code cleanup
Date Thu, 08 Feb 2018 13:01:58 GMT
Code cleanup


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

Branch: refs/heads/master
Commit: 162d06e463691e8dc9ecc59ff5964180b97d3f7e
Parents: bc8441a
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Feb 8 14:41:13 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Feb 8 14:41:13 2018 +0300

----------------------------------------------------------------------
 .../java/org/apache/cayenne/dbsync/naming/NameUtil.java     | 6 ++++--
 .../cayenne/dbsync/reverse/configuration/ToolsModule.java   | 9 +++------
 .../src/main/java/org/apache/cayenne/map/ObjAttribute.java  | 2 +-
 3 files changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/162d06e4/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/NameUtil.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/NameUtil.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/NameUtil.java
index 47e6fd2..e0eea81 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/NameUtil.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/naming/NameUtil.java
@@ -18,14 +18,15 @@
  */
 package org.apache.cayenne.dbsync.naming;
 
+import org.apache.cayenne.util.Util;
+
 /**
  * @since 4.0
  */
 final class NameUtil {
 
     private static String prepare(String string, boolean capitalize){
-        int len;
-        if (string == null || (len = string.length()) == 0) {
+        if (Util.isEmptyString(string)) {
             return string;
         }
 
@@ -36,6 +37,7 @@ final class NameUtil {
             return string;
         }
 
+        int len = string.length();
         char[] newChars = new char[len];
         newChars[0] = newChar;
         string.getChars(1, len, newChars, 1);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/162d06e4/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
index 1ab51f0..ceb1e11 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
@@ -19,6 +19,8 @@
 
 package org.apache.cayenne.dbsync.reverse.configuration;
 
+import java.util.Objects;
+
 import org.apache.cayenne.access.translator.batch.BatchTranslatorFactory;
 import org.apache.cayenne.access.translator.batch.DefaultBatchTranslatorFactory;
 import org.apache.cayenne.access.types.DefaultValueObjectTypeRegistry;
@@ -79,12 +81,7 @@ public class ToolsModule implements Module {
     private Logger logger;
 
     public ToolsModule(Logger logger) {
-
-        if (logger == null) {
-            throw new NullPointerException("Null logger");
-        }
-
-        this.logger = logger;
+        this.logger = Objects.requireNonNull(logger);
     }
 
     public void configure(Binder binder) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/162d06e4/cayenne-server/src/main/java/org/apache/cayenne/map/ObjAttribute.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/ObjAttribute.java b/cayenne-server/src/main/java/org/apache/cayenne/map/ObjAttribute.java
index ebafe84..ad9c42b 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/ObjAttribute.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/ObjAttribute.java
@@ -294,7 +294,7 @@ public class ObjAttribute extends Attribute implements ConfigurationNode
{
      */
     public boolean isMandatory() {
         DbAttribute dbAttribute = getDbAttribute();
-        return dbAttribute == null ? false : dbAttribute.isMandatory();
+        return dbAttribute != null && dbAttribute.isMandatory();
     }
 
     /**


Mime
View raw message