deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-1067 Data module should use utils from core
Date Sun, 31 Jan 2016 12:27:42 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master b96a797af -> 7c267ba0e


DELTASPIKE-1067 Data module should use utils from core

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/7c267ba0
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/7c267ba0
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/7c267ba0

Branch: refs/heads/master
Commit: 7c267ba0e8028e890d7169f581092789ac8f189e
Parents: b96a797
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Sun Jan 31 13:27:34 2016 +0100
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Sun Jan 31 13:27:34 2016 +0100

----------------------------------------------------------------------
 .../deltaspike/core/util/ArraysUtils.java       |  5 +++
 .../deltaspike/core/util/CollectionUtils.java   | 39 ++++++++++++++++++++
 .../deltaspike/core/util/StringUtils.java       |  5 +++
 .../impl/builder/AnnotatedQueryBuilder.java     |  2 +-
 .../impl/builder/part/OrderByQueryPart.java     |  2 +-
 .../postprocessor/CountQueryPostProcessor.java  |  2 +-
 .../impl/handler/EntityRepositoryHandler.java   |  2 +-
 .../data/impl/meta/RepositoryMethod.java        |  2 +-
 .../data/impl/meta/unit/EntityDescriptor.java   |  2 +-
 .../meta/unit/MappedSuperclassDescriptor.java   |  5 +--
 .../deltaspike/data/impl/util/QueryUtils.java   | 24 +-----------
 11 files changed, 59 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ArraysUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ArraysUtils.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ArraysUtils.java
index ccef603..20c5e8c 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ArraysUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ArraysUtils.java
@@ -48,4 +48,9 @@ public abstract class ArraysUtils
         Collections.addAll(result, array);
         return result;
     }
+
+    public static boolean isEmpty(Object[] array)
+    {
+        return array == null || array.length == 0;
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/CollectionUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/CollectionUtils.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/CollectionUtils.java
new file mode 100644
index 0000000..c1f3e31
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/CollectionUtils.java
@@ -0,0 +1,39 @@
+/*
+ * 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.deltaspike.core.util;
+
+import java.util.Collection;
+import javax.enterprise.inject.Typed;
+
+/**
+ * A collection of utilities for working with Collections
+ */
+@Typed()
+public abstract class CollectionUtils
+{
+    private CollectionUtils()
+    {
+        // prevent instantiation
+    }
+
+    public static boolean isEmpty(Collection<?> collection)
+    {
+        return collection == null || collection.isEmpty();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/StringUtils.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/StringUtils.java
index e6761ac..7f70385 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/StringUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/StringUtils.java
@@ -35,4 +35,9 @@ public abstract class StringUtils
     {
         return string == null || string.trim().isEmpty();
     }
+
+    public static boolean isNotEmpty(String text)
+    {
+        return !isEmpty(text);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
index a4393df..4421717 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
@@ -28,7 +28,7 @@ import org.apache.deltaspike.data.impl.util.jpa.QueryStringExtractorFactory;
 import javax.persistence.EntityManager;
 import java.lang.reflect.Method;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isNotEmpty;
+import static org.apache.deltaspike.core.util.StringUtils.isNotEmpty;
 
 /**
  * Create the query based on method annotations.

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
index 9e87b8f..f1ebb3b 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
@@ -18,7 +18,7 @@
  */
 package org.apache.deltaspike.data.impl.builder.part;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isNotEmpty;
+import static org.apache.deltaspike.core.util.StringUtils.isNotEmpty;
 import static org.apache.deltaspike.data.impl.util.QueryUtils.splitByKeyword;
 import static org.apache.deltaspike.data.impl.util.QueryUtils.uncapitalize;
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/postprocessor/CountQueryPostProcessor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/postprocessor/CountQueryPostProcessor.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/postprocessor/CountQueryPostProcessor.java
index c781d21..d71afa4 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/postprocessor/CountQueryPostProcessor.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/postprocessor/CountQueryPostProcessor.java
@@ -18,7 +18,7 @@
  */
 package org.apache.deltaspike.data.impl.builder.postprocessor;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isNotEmpty;
+import static org.apache.deltaspike.core.util.StringUtils.isNotEmpty;
 import static org.apache.deltaspike.data.impl.util.QueryUtils.nullSafeValue;
 
 import java.util.logging.Level;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
index abd9842..19fa0fa 100755
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
@@ -46,7 +46,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isEmpty;
+import static org.apache.deltaspike.core.util.ArraysUtils.isEmpty;
 import static org.apache.deltaspike.data.impl.util.QueryUtils.isString;
 
 /**

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryMethod.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryMethod.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryMethod.java
index 611f7b5..f56ffaf 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryMethod.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryMethod.java
@@ -18,7 +18,7 @@
  */
 package org.apache.deltaspike.data.impl.meta;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isNotEmpty;
+import static org.apache.deltaspike.core.util.StringUtils.isNotEmpty;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/EntityDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/EntityDescriptor.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/EntityDescriptor.java
index 9d8a78c..6469baa 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/EntityDescriptor.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/EntityDescriptor.java
@@ -20,7 +20,7 @@ package org.apache.deltaspike.data.impl.meta.unit;
 
 import java.io.Serializable;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isEmpty;
+import static org.apache.deltaspike.core.util.StringUtils.isEmpty;
 
 class EntityDescriptor extends PersistentClassDescriptor
 {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/MappedSuperclassDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/MappedSuperclassDescriptor.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/MappedSuperclassDescriptor.java
index 6c5ffe9..58d752b 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/MappedSuperclassDescriptor.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/unit/MappedSuperclassDescriptor.java
@@ -18,9 +18,8 @@
  */
 package org.apache.deltaspike.data.impl.meta.unit;
 
-import static org.apache.deltaspike.data.impl.util.QueryUtils.isEmpty;
-
 import java.io.Serializable;
+import org.apache.deltaspike.core.util.StringUtils;
 
 class MappedSuperclassDescriptor extends PersistentClassDescriptor
 {
@@ -44,7 +43,7 @@ class MappedSuperclassDescriptor extends PersistentClassDescriptor
     @Override
     public String getId()
     {
-        if (isEmpty(id) && getParent() != null)
+        if (StringUtils.isEmpty(id) && getParent() != null)
         {
             return getParent().getId();
         }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/7c267ba0/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/QueryUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/QueryUtils.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/QueryUtils.java
index 306ab5b..8ea9484 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/QueryUtils.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/QueryUtils.java
@@ -19,7 +19,7 @@
 package org.apache.deltaspike.data.impl.util;
 
 import java.text.MessageFormat;
-import java.util.Collection;
+import org.apache.deltaspike.core.util.StringUtils;
 
 public final class QueryUtils
 {
@@ -36,7 +36,7 @@ public final class QueryUtils
 
     public static String uncapitalize(String value)
     {
-        if (isEmpty(value))
+        if (StringUtils.isEmpty(value))
         {
             return null;
         }
@@ -47,26 +47,6 @@ public final class QueryUtils
         return value.substring(0, 1).toLowerCase() + value.substring(1);
     }
 
-    public static boolean isEmpty(String text)
-    {
-        return text == null || "".equals(text);
-    }
-
-    public static boolean isNotEmpty(String text)
-    {
-        return !isEmpty(text);
-    }
-
-    public static boolean isEmpty(Collection<?> collection)
-    {
-        return collection == null || collection.isEmpty();
-    }
-
-    public static boolean isEmpty(Object[] array)
-    {
-        return array == null || array.length == 0;
-    }
-
     public static boolean isString(Object value)
     {
         return value != null && value instanceof String;


Mime
View raw message