You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2015/05/03 20:22:35 UTC

svn commit: r1677471 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java

Author: struberg
Date: Sun May  3 18:22:35 2015
New Revision: 1677471

URL: http://svn.apache.org/r1677471
Log:
add a simple StringUtil with static helpers

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java?rev=1677471&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/StringUtil.java Sun May  3 18:22:35 2015
@@ -0,0 +1,54 @@
+/*
+ * 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.webbeans.util;
+
+/**
+ * a few static string utility methods
+ */
+public final class StringUtil
+{
+    private StringUtil()
+    {
+        // private utility class ct
+    }
+
+    /**
+     * @return {@code true} if the given string is either {@code null} or an empty string
+     */
+    public static boolean isEmpty(String val)
+    {
+        return val == null || val.length() == 0;
+    }
+
+    /**
+     * @return {@code true} if the given string is not null and has a content
+     */
+    public static boolean isNotEmpty(String val)
+    {
+        return val != null && val.length() > 0;
+    }
+
+    /**
+     * @return {@code true} if the given string is either {@code null} or an empty or blank string
+     */
+    public static boolean isBlank(String val)
+    {
+        return val == null || val.length() == 0 || val.trim().length() == 0;
+    }
+}