Author: mthl
Date: Sat Jul 20 16:24:39 2019
New Revision: 1863493
URL:
http://svn.apache.org/viewvc?rev=1863493&view=revLog:
Improved: Inline ‘UtilGenerics#checkCollectionContainment’
(OFBIZ-11141)
Modified:
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java?rev=1863493&r1=1863492&r2=1863493&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java Sat Jul 20 16:24:39 2019
@@ -35,10 +35,14 @@ public final class UtilGenerics {
return (V) object;
}
- public static <C extends Collection<?>> void checkCollectionContainment(Object object, Class<C> clz, Class<?> type) {
+ public static <T> Collection<T> checkCollection(Object object) {
+ return cast(object);
+ }
+
+ public static <E, C extends Collection<E>> C checkCollection(Object object, Class<E> type) {
if (object != null) {
- if (!(clz.isInstance(object))) {
- throw new ClassCastException("Not a " + clz.getName());
+ if (!(Collection.class.isInstance(object))) {
+ throw new ClassCastException("Not a " + Collection.class.getName());
}
int i = 0;
for (Object value: (Collection<?>) object) {
@@ -48,14 +52,6 @@ public final class UtilGenerics {
i++;
}
}
- }
-
- public static <T> Collection<T> checkCollection(Object object) {
- return cast(object);
- }
-
- public static <E, C extends Collection<E>> C checkCollection(Object object, Class<E> type) {
- checkCollectionContainment(object, Collection.class, type);
return cast(object);
}