You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/10/25 14:04:26 UTC

svn commit: r588206 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java

Author: jonesde
Date: Thu Oct 25 05:04:23 2007
New Revision: 588206

URL: http://svn.apache.org/viewvc?rev=588206&view=rev
Log:
A handy little method to facilitate some GenericDelegator new/enhanced methods that are now using Set instead of Collection as they should be

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java?rev=588206&r1=588205&r2=588206&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java Thu Oct 25 05:04:23 2007
@@ -267,6 +267,19 @@
         return lst.remove(0);
     }
     
+    public static <T> Set<T> collectionToSet(Collection<T> c) {
+        if (c == null) return null;
+        Set theSet = null;
+        if (c instanceof Set) {
+            theSet = (Set) c;
+        } else {
+            theSet = FastSet.newInstance();
+            c.remove(null);
+            theSet.addAll(c);
+        }
+        return theSet;
+    }
+    
     /**
      * Create a Set from passed objX parameters
      * @return The resulting Set