From 7db8f19d08d48b13f168baf871f6f09e5131a35c Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 20 Jul 2019 16:24:39 +0000 Subject: [PATCH] =?UTF-8?q?Improved:=20Inline=20=E2=80=98UtilGenerics#chec?= =?UTF-8?q?kCollectionContainment=E2=80=99=20(OFBIZ-11141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863493 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/ofbiz/base/util/UtilGenerics.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java index 286a2fc071..2813d81f04 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java @@ -35,10 +35,14 @@ public final class UtilGenerics { return (V) object; } - public static > void checkCollectionContainment(Object object, Class clz, Class type) { + public static Collection checkCollection(Object object) { + return cast(object); + } + + public static > C checkCollection(Object object, Class 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 Collection checkCollection(Object object) { - return cast(object); - } - - public static > C checkCollection(Object object, Class type) { - checkCollectionContainment(object, Collection.class, type); return cast(object); }