Author: doogie
Date: Mon Sep 22 11:21:42 2008
New Revision: 697926
URL:
http://svn.apache.org/viewvc?rev=697926&view=revLog:
Slight change to getFieldListFromEntityList*, so that calling code
can automatically have it cast to the correct container type.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java?rev=697926&r1=697925&r2=697926&view=diff==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java Mon Sep 22 11:21:42 2008
@@ -34,6 +34,7 @@
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.GenericDelegator;
@@ -455,18 +456,18 @@
}
}
- public static List<Object> getFieldListFromEntityList(List<GenericValue> genericValueList, String fieldName, boolean distinct) {
+ public static <T> List<T> getFieldListFromEntityList(List<GenericValue> genericValueList, String fieldName, boolean distinct) {
if (genericValueList == null || fieldName == null) {
return null;
}
- List<Object> fieldList = FastList.newInstance();
- Set<Object> distinctSet = null;
+ List<T> fieldList = FastList.newInstance();
+ Set<T> distinctSet = null;
if (distinct) {
distinctSet = FastSet.newInstance();
}
for (GenericValue value: genericValueList) {
- Object fieldValue = value.get(fieldName);
+ T fieldValue = UtilGenerics.<T>cast(value.get(fieldName));
if (fieldValue != null) {
if (distinct) {
if (!distinctSet.contains(fieldValue)) {
@@ -482,19 +483,19 @@
return fieldList;
}
- public static List<Object> getFieldListFromEntityListIterator(EntityListIterator genericValueEli, String fieldName, boolean distinct) {
+ public static <T> List<T> getFieldListFromEntityListIterator(EntityListIterator genericValueEli, String fieldName, boolean distinct) {
if (genericValueEli == null || fieldName == null) {
return null;
}
- List<Object> fieldList = FastList.newInstance();
- Set<Object> distinctSet = null;
+ List<T> fieldList = FastList.newInstance();
+ Set<T> distinctSet = null;
if (distinct) {
distinctSet = FastSet.newInstance();
}
GenericValue value = null;
while ((value = genericValueEli.next()) != null) {
- Object fieldValue = value.get(fieldName);
+ T fieldValue = UtilGenerics.<T>cast(value.get(fieldName));
if (fieldValue != null) {
if (distinct) {
if (!distinctSet.contains(fieldValue)) {