You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2010/06/02 23:24:01 UTC
svn commit: r950764 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base:
lang/IsEmpty.java util/ObjectType.java util/UtilValidate.java
Author: doogie
Date: Wed Jun 2 21:24:00 2010
New Revision: 950764
URL: http://svn.apache.org/viewvc?rev=950764&view=rev
Log:
Add a new marker interface, IsEmpty.
Added:
ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/IsEmpty.java
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java
Added: ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/IsEmpty.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/IsEmpty.java?rev=950764&view=auto
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/IsEmpty.java (added)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/lang/IsEmpty.java Wed Jun 2 21:24:00 2010
@@ -0,0 +1,23 @@
+/*
+ * 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.ofbiz.base.lang;
+
+public interface IsEmpty {
+ boolean isEmpty();
+}
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=950764&r1=950763&r2=950764&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java Wed Jun 2 21:24:00 2010
@@ -33,6 +33,7 @@ import org.ofbiz.base.conversion.Convers
import org.ofbiz.base.conversion.Converter;
import org.ofbiz.base.conversion.Converters;
import org.ofbiz.base.conversion.LocalizedConverter;
+import org.ofbiz.base.lang.IsEmpty;
import org.ofbiz.base.lang.SourceMonitored;
import org.w3c.dom.Node;
@@ -768,6 +769,7 @@ public class ObjectType {
if (value instanceof Collection) return UtilValidate.isEmpty((Collection<? extends Object>) value);
if (value instanceof Map) return UtilValidate.isEmpty((Map<? extends Object, ? extends Object>) value);
if (value instanceof CharSequence) return UtilValidate.isEmpty((CharSequence) value);
+ if (value instanceof IsEmpty) return UtilValidate.isEmpty((IsEmpty) value);
// These types would flood the log
// Number covers: BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java?rev=950764&r1=950763&r2=950764&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java Wed Jun 2 21:24:00 2010
@@ -25,6 +25,8 @@ import java.util.Map;
import org.apache.commons.validator.EmailValidator;
+import org.ofbiz.base.lang.IsEmpty;
+
/**
* General input/data validation methods
* Utility methods for validating data, especially input.
@@ -192,6 +194,16 @@ public class UtilValidate {
return !ObjectType.isEmpty(o);
}
+ /** Check whether IsEmpty o is empty. */
+ public static boolean isEmpty(IsEmpty o) {
+ return o == null || o.isEmpty();
+ }
+
+ /** Check whether IsEmpty o is NOT empty. */
+ public static boolean isNotEmpty(IsEmpty o) {
+ return o != null && !o.isEmpty();
+ }
+
/** Check whether string s is empty. */
public static boolean isEmpty(String s) {
return ((s == null) || (s.length() == 0));