Author: jleroux
Date: Wed Nov 18 04:54:18 2009 New Revision: 881669 URL: http://svn.apache.org/viewvc?rev=881669&view=rev Log: A patch from Bob Morley "Resolve java warnings exposed in Eclipse : framework - entity" (https://issues.apache.org/jira/browse/OFBIZ-3107) - OFBIZ-3107 Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityClause.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataAssert.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityTypeUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java Wed Nov 18 04:54:18 2009 @@ -505,7 +505,7 @@ public String getDelegatorName(); - public EntityEcaHandler getEntityEcaHandler(); + public <T> EntityEcaHandler<T> getEntityEcaHandler(); /** * Gets a field type instance by name from the helper that corresponds to @@ -1095,7 +1095,7 @@ public void setEntityCrypto(EntityCrypto crypto); - public void setEntityEcaHandler(EntityEcaHandler entityEcaHandler); + public <T> void setEntityEcaHandler(EntityEcaHandler<T> entityEcaHandler); /** * Look at existing values for a sub-entity with a sequenced secondary ID, Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Wed Nov 18 04:54:18 2009 @@ -39,10 +39,10 @@ import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; -import org.ofbiz.base.util.cache.UtilCache; import org.ofbiz.entity.cache.Cache; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityConditionList; @@ -102,7 +102,7 @@ protected Cache cache = null; /** keeps a list of field key sets used in the by and cache, a Set (of Sets of fieldNames) for each entityName */ - protected Map andCacheFieldSets = FastMap.newInstance(); + protected Map<?,?> andCacheFieldSets = FastMap.newInstance(); protected DistributedCacheClear distributedCacheClear = null; protected EntityEcaHandler<?> entityEcaHandler = null; @@ -288,7 +288,7 @@ String distributedCacheClearClassName = getDelegatorInfo().distributedCacheClearClassName; try { - Class dccClass = loader.loadClass(distributedCacheClearClassName); + Class<?> dccClass = loader.loadClass(distributedCacheClearClassName); this.distributedCacheClear = (DistributedCacheClear) dccClass.newInstance(); this.distributedCacheClear.setDelegator(this, getDelegatorInfo().distributedCacheClearUserLoginId); } catch (ClassNotFoundException e) { @@ -318,8 +318,8 @@ String entityEcaHandlerClassName = getDelegatorInfo().entityEcaHandlerClassName; try { - Class eecahClass = loader.loadClass(entityEcaHandlerClassName); - this.entityEcaHandler = (EntityEcaHandler) eecahClass.newInstance(); + Class<?> eecahClass = loader.loadClass(entityEcaHandlerClassName); + this.entityEcaHandler = UtilGenerics.cast(eecahClass.newInstance()); this.entityEcaHandler.setDelegator(this); } catch (ClassNotFoundException e) { Debug.logWarning(e, "EntityEcaHandler class with name " + entityEcaHandlerClassName + " was not found, Entity ECA Rules will be disabled", module); @@ -2807,15 +2807,15 @@ /* (non-Javadoc) * @see org.ofbiz.entity.Delegator#setEntityEcaHandler(org.ofbiz.entity.eca.EntityEcaHandler) */ - public void setEntityEcaHandler(EntityEcaHandler entityEcaHandler) { + public <T> void setEntityEcaHandler(EntityEcaHandler<T> entityEcaHandler) { this.entityEcaHandler = entityEcaHandler; } /* (non-Javadoc) * @see org.ofbiz.entity.Delegator#getEntityEcaHandler() */ - public EntityEcaHandler getEntityEcaHandler() { - return this.entityEcaHandler; + public <T> EntityEcaHandler<T> getEntityEcaHandler() { + return UtilGenerics.cast(this.entityEcaHandler); } /* (non-Javadoc) Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Wed Nov 18 04:54:18 2009 @@ -67,7 +67,7 @@ * <code>Observer</code>. * */ -public class GenericEntity extends Observable implements Map<String, Object>, LocalizedMap, Serializable, Comparable<GenericEntity>, Cloneable, Reusable { +public class GenericEntity extends Observable implements Map<String, Object>, LocalizedMap<Object>, Serializable, Comparable<GenericEntity>, Cloneable, Reusable { public static final String module = GenericEntity.class.getName(); public static final GenericEntity NULL_ENTITY = new NullGenericEntity(); @@ -1009,9 +1009,9 @@ // else element = new ElementImpl(null, this.getEntityName()); if (element == null) return null; - Iterator modelFields = this.getModelEntity().getFieldsIterator(); + Iterator<ModelField> modelFields = this.getModelEntity().getFieldsIterator(); while (modelFields.hasNext()) { - ModelField modelField = (ModelField) modelFields.next(); + ModelField modelField = modelFields.next(); String name = modelField.getName(); String value = this.getString(name); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java Wed Nov 18 04:54:18 2009 @@ -109,7 +109,7 @@ return conditionCache; } - protected static final boolean isNull(Map value) { + protected static final <K,V> boolean isNull(Map<K,V> value) { return value == null || value == GenericEntity.NULL_ENTITY || value == GenericValue.NULL_VALUE; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java Wed Nov 18 04:54:18 2009 @@ -18,12 +18,10 @@ *******************************************************************************/ package org.ofbiz.entity.cache; -import java.util.Iterator; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.cache.UtilCache; -import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.GenericPK; +import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; public class EntityCache extends AbstractCache<GenericPK, GenericValue> { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityClause.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityClause.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityClause.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityClause.java Wed Nov 18 04:54:18 2009 @@ -20,6 +20,7 @@ package org.ofbiz.entity.condition; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelReader; @@ -36,13 +37,13 @@ private String secondField = ""; private ModelEntity firstModelEntity = null; private ModelEntity secondModelEntity = null; - private EntityOperator interFieldOperation = null; - private EntityOperator intraFieldOperation = null; + private EntityOperator<?,?,?> interFieldOperation = null; + private EntityOperator<?,?,?> intraFieldOperation = null; private Object value = null; public EntityClause() {} - public EntityClause(String firstEntity, String secondEntity, String firstField, String secondField, EntityOperator interFieldOperation, EntityOperator intraFieldOperation) { + public EntityClause(String firstEntity, String secondEntity, String firstField, String secondField, EntityOperator<?, ?, ?> interFieldOperation, EntityOperator<?, ?, ?> intraFieldOperation) { this.firstEntity = firstEntity; this.secondEntity = secondEntity; this.firstField = firstField; @@ -51,7 +52,7 @@ this.intraFieldOperation = intraFieldOperation; } - public EntityClause(String firstEntity, String firstField, Object value, EntityOperator interFieldOperation, EntityOperator intraFieldOperation) { + public EntityClause(String firstEntity, String firstField, Object value, EntityOperator<?, ?, ?> interFieldOperation, EntityOperator<?, ?, ?> intraFieldOperation) { this.firstEntity = firstEntity; this.firstField = firstField; this.value = value; @@ -80,12 +81,12 @@ return value; } - public EntityOperator getInterFieldOperation() { - return interFieldOperation; + public <L,R,T> EntityOperator<L,R,T> getInterFieldOperation() { + return UtilGenerics.cast(interFieldOperation); } - public EntityOperator getIntraFieldOperation() { - return intraFieldOperation; + public <L,R,T> EntityOperator<L,R,T> getIntraFieldOperation() { + return UtilGenerics.cast(intraFieldOperation); } public void setFirstEntity(String firstEntity) { @@ -104,11 +105,11 @@ this.secondField = secondField; } - public void setInterFieldOperation(EntityOperator interFieldOperation) { + public <L,R,T> void setInterFieldOperation(EntityOperator<L,R,T> interFieldOperation) { this.interFieldOperation = interFieldOperation; } - public void setIntraFieldOperation(EntityOperator intraFieldOperation) { + public <L,R,T> void setIntraFieldOperation(EntityOperator<L,R,T> intraFieldOperation) { this.intraFieldOperation = intraFieldOperation; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java Wed Nov 18 04:54:18 2009 @@ -31,6 +31,7 @@ import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericModelException; @@ -68,7 +69,7 @@ } @Override - public void validateSql(ModelEntity entity, Object lhs, Object rhs) throws GenericModelException { + public void validateSql(ModelEntity entity, L lhs, R rhs) throws GenericModelException { if (lhs instanceof EntityConditionValue) { EntityConditionValue ecv = (EntityConditionValue) lhs; ecv.validateSql(entity); @@ -80,13 +81,13 @@ } @Override - public void visit(EntityConditionVisitor visitor, Object lhs, Object rhs) { + public void visit(EntityConditionVisitor visitor, L lhs, R rhs) { visitor.accept(lhs); visitor.accept(rhs); } @Override - public void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, boolean compat, Object lhs, Object rhs, DatasourceInfo datasourceInfo) { + public void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, boolean compat, L lhs, R rhs, DatasourceInfo datasourceInfo) { //Debug.logInfo("EntityComparisonOperator.addSqlValue field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module); // if this is an IN operator and the rhs Object isEmpty, add "1=0" instead of the normal SQL. Note that "FALSE" does not work with all databases. @@ -115,12 +116,12 @@ makeRHSWhereString(entity, entityConditionParams, sql, field, rhs, datasourceInfo); } - protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sql, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { + protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sql, ModelField field, R rhs, DatasourceInfo datasourceInfo) { sql.append(' ').append(getCode()).append(' '); makeRHSWhereStringValue(entity, entityConditionParams, sql, field, rhs, datasourceInfo); } - protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sql, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { + protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sql, ModelField field, R rhs, DatasourceInfo datasourceInfo) { if (rhs instanceof EntityConditionValue) { EntityConditionValue ecv = (EntityConditionValue) rhs; ecv.addSqlValue(sql, entity, entityConditionParams, false, datasourceInfo); @@ -131,13 +132,12 @@ public abstract boolean compare(L lhs, R rhs); - public Boolean eval(Delegator delegator, Map<String, ? extends Object> map, Object lhs, Object rhs) { + public Boolean eval(Delegator delegator, Map<String, ? extends Object> map, L lhs, R rhs) { return Boolean.valueOf(mapMatches(delegator, map, lhs, rhs)); } @Override - @SuppressWarnings("unchecked") - public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, Object lhs, Object rhs) { + public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, L lhs, R rhs) { Object leftValue; if (lhs instanceof EntityConditionValue) { EntityConditionValue ecv = (EntityConditionValue) lhs; @@ -156,11 +156,11 @@ } if (leftValue == WILDCARD || rightValue == WILDCARD) return true; - return compare((L) leftValue, (R) rightValue); + return compare(UtilGenerics.<L>cast(leftValue), UtilGenerics.<R>cast(rightValue)); } @Override - public EntityCondition freeze(Object lhs, Object rhs) { + public EntityCondition freeze(L lhs, R rhs) { return EntityCondition.makeCondition(freeze(lhs), this, freeze(rhs)); } @@ -177,7 +177,7 @@ super(id, code); } - public static final boolean compareEqual(Comparable lhs, Object rhs) { + public static final <T> boolean compareEqual(Comparable<T> lhs, T rhs) { if (lhs == null) { if (rhs != null) { return false; @@ -188,7 +188,7 @@ return true; } - public static final boolean compareNotEqual(Comparable lhs, Object rhs) { + public static final <T> boolean compareNotEqual(Comparable<T> lhs, T rhs) { if (lhs == null) { if (rhs == null) { return false; @@ -243,7 +243,7 @@ return true; } - public static final boolean compareIn(Object lhs, Object rhs) { + public static final <L,R> boolean compareIn(L lhs, R rhs) { if (lhs == null) { if (rhs != null) { return false; @@ -251,7 +251,7 @@ return true; } } else if (rhs instanceof Collection) { - if (((Collection) rhs).contains(lhs)) { + if (((Collection<?>) rhs).contains(lhs)) { return true; } else { return false; @@ -263,7 +263,7 @@ } } - public static final boolean compareLike(Object lhs, Object rhs) { + public static final <L,R> boolean compareLike(L lhs, R rhs) { if (lhs == null) { if (rhs != null) { return false; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Wed Nov 18 04:54:18 2009 @@ -18,13 +18,14 @@ *******************************************************************************/ package org.ofbiz.entity.condition; +import static org.ofbiz.base.util.UtilGenerics.cast; + import java.util.List; import java.util.Map; import javolution.lang.Reusable; import javolution.util.FastList; -import static org.ofbiz.base.util.UtilGenerics.cast; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericModelException; @@ -44,13 +45,13 @@ */ public abstract class EntityCondition extends EntityConditionBase implements Reusable { - public static EntityExpr makeCondition(Object lhs, EntityComparisonOperator operator, Object rhs) { + public static <L,R,LL,RR> EntityExpr makeCondition(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) { EntityExpr expr = EntityExpr.entityExprFactory.object(); expr.init(lhs, operator, rhs); return expr; } - public static EntityExpr makeCondition(String fieldName, Object value) { + public static <R> EntityExpr makeCondition(String fieldName, R value) { EntityExpr expr = EntityExpr.entityExprFactory.object(); expr.init(fieldName, EntityOperator.EQUALS, value); return expr; @@ -86,7 +87,7 @@ return ecl; } - public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { + public static <L,R> EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp) { EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(fieldMap, compOp, joinOp); return efm; @@ -104,7 +105,7 @@ return efm; } - public static EntityFieldMap makeCondition(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { + public static <L,R> EntityFieldMap makeCondition(EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp, Object... keysValues) { EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(compOp, joinOp, keysValues); return efm; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java Wed Nov 18 04:54:18 2009 @@ -47,8 +47,8 @@ @SuppressWarnings("serial") public abstract class EntityConditionBase implements Serializable { - public static final List emptyList = Collections.unmodifiableList(FastList.newInstance()); - public static final Map _emptyMap = Collections.unmodifiableMap(FastMap.newInstance()); + public static final List<?> emptyList = Collections.unmodifiableList(FastList.newInstance()); + public static final Map<?,?> _emptyMap = Collections.unmodifiableMap(FastMap.newInstance()); public static final Map<String, String> emptyAliases = Collections.unmodifiableMap(FastMap.<String, String>newInstance()); protected ModelField getField(ModelEntity modelEntity, String fieldName) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java Wed Nov 18 04:54:18 2009 @@ -30,10 +30,10 @@ public class EntityConditionList<T extends EntityCondition> extends EntityConditionListBase<T> { public static final String module = EntityConditionList.class.getName(); - protected static final ObjectFactory<EntityConditionList> entityConditionListFactory = new ObjectFactory<EntityConditionList>() { + protected static final ObjectFactory<EntityConditionList<EntityCondition>> entityConditionListFactory = new ObjectFactory<EntityConditionList<EntityCondition>>() { @Override - protected EntityConditionList create() { - return new EntityConditionList(); + protected EntityConditionList<EntityCondition> create() { + return new EntityConditionList<EntityCondition>(); } }; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java Wed Nov 18 04:54:18 2009 @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericModelException; import org.ofbiz.entity.config.DatasourceInfo; @@ -63,7 +64,7 @@ this.operator = null; } - public EntityOperator getOperator() { + public EntityJoinOperator getOperator() { return this.operator; } @@ -118,7 +119,7 @@ @Override public boolean equals(Object obj) { if (!(obj instanceof EntityConditionListBase)) return false; - EntityConditionListBase other = (EntityConditionListBase) obj; + EntityConditionListBase<?> other = UtilGenerics.cast(obj); boolean isEqual = conditionList.equals(other.conditionList) && operator.equals(other.operator); //if (!isEqual) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java Wed Nov 18 04:54:18 2009 @@ -127,7 +127,7 @@ } @Override - public Comparable getValue(Delegator delegator, Map<String, ? extends Object> map) { + public Comparable<?> getValue(Delegator delegator, Map<String, ? extends Object> map) { // do nothing for now return null; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java Wed Nov 18 04:54:18 2009 @@ -33,21 +33,21 @@ * */ public interface EntityConditionVisitor { - void visit(Object obj); - void accept(Object obj); + <T> void visit(T obj); + <T> void accept(T obj); void acceptObject(Object obj); void acceptEntityCondition(EntityCondition condition); - void acceptEntityJoinOperator(EntityJoinOperator op, List conditions); - void acceptEntityOperator(EntityOperator op, Object lhs, Object rhs); - void acceptEntityComparisonOperator(EntityComparisonOperator op, Object lhs, Object rhs); + <T extends EntityCondition> void acceptEntityJoinOperator(EntityJoinOperator op, List<T> conditions); + <L,R,T> void acceptEntityOperator(EntityOperator<L, R, T> op, L lhs, R rhs); + <L,R> void acceptEntityComparisonOperator(EntityComparisonOperator<L, R> op, L lhs, R rhs); void acceptEntityConditionValue(EntityConditionValue value); void acceptEntityFieldValue(EntityFieldValue value); void acceptEntityExpr(EntityExpr expr); - void acceptEntityConditionList(EntityConditionList list); + <T extends EntityCondition> void acceptEntityConditionList(EntityConditionList<T> list); void acceptEntityFieldMap(EntityFieldMap fieldMap); void acceptEntityConditionFunction(EntityConditionFunction func, EntityCondition nested); - void acceptEntityFunction(EntityFunction func); + <T extends Comparable<?>> void acceptEntityFunction(EntityFunction<T> func); void acceptEntityWhereString(EntityWhereString condition); void acceptEntityDateFilterCondition(EntityDateFilterCondition condition); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Wed Nov 18 04:54:18 2009 @@ -25,6 +25,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.EntityCryptoException; @@ -52,27 +53,29 @@ }; private Object lhs = null; - private EntityOperator<?, ?, ?> operator = null; + private EntityOperator<Object, Object, ?> operator = null; private Object rhs = null; protected EntityExpr() {} /** @deprecated Use EntityCondition.makeCondition() instead */ @Deprecated - public EntityExpr(Object lhs, EntityComparisonOperator operator, Object rhs) { + public <L,R> EntityExpr(L lhs, EntityComparisonOperator<L,R> operator, R rhs) { this.init(lhs, operator, rhs); } /** @deprecated Use EntityCondition.makeCondition() instead */ @Deprecated - public EntityExpr(String lhs, EntityComparisonOperator operator, Object rhs) { + public <R> EntityExpr(String lhs, EntityComparisonOperator<String,R> operator, R rhs) { this.init(lhs, operator, rhs); } /** @deprecated Use EntityCondition.makeCondition() instead */ @Deprecated - public EntityExpr(String lhs, boolean leftUpper, EntityComparisonOperator operator, Object rhs, boolean rightUpper) { - this.init(leftUpper ? EntityFunction.UPPER_FIELD(lhs) : lhs, operator, rightUpper ? EntityFunction.UPPER(rhs) : rhs); + public <L,R> EntityExpr(L lhs, boolean leftUpper, EntityComparisonOperator<L,R> operator, R rhs, boolean rightUpper) { + L l = leftUpper ? UtilGenerics.<L>cast(EntityFunction.UPPER_FIELD((String)lhs)) : lhs; + R r = rightUpper ? UtilGenerics.<R>cast(EntityFunction.UPPER(rhs)) : rhs; + this.init(l, operator, r); } /** @deprecated Use EntityCondition.makeCondition() instead */ @@ -81,7 +84,7 @@ this.init(lhs, operator, rhs); } - public void init(Object lhs, EntityComparisonOperator operator, Object rhs) { + public <L,R,LL,RR> void init(L lhs, EntityComparisonOperator<LL,RR> operator, R rhs) { if (lhs == null) { throw new IllegalArgumentException("The field name/value cannot be null"); } @@ -96,7 +99,7 @@ } if (EntityOperator.BETWEEN.equals(operator)) { - if (!(rhs instanceof Collection) || (((Collection) rhs).size() != 2)) { + if (!(rhs instanceof Collection) || (((Collection<?>) rhs).size() != 2)) { throw new IllegalArgumentException("BETWEEN Operator requires a Collection with 2 elements for the right/rhs argument"); } } @@ -106,7 +109,7 @@ } else { this.lhs = lhs; } - this.operator = operator; + this.operator = UtilGenerics.cast(operator); this.rhs = rhs; //Debug.logInfo("new EntityExpr internal field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module); @@ -124,7 +127,7 @@ } this.lhs = lhs; - this.operator = operator; + this.operator = UtilGenerics.cast(operator); this.rhs = rhs; } @@ -160,8 +163,8 @@ return lhs; } - public EntityOperator getOperator() { - return operator; + public <L,R,T> EntityOperator<L,R,T> getOperator() { + return UtilGenerics.cast(operator); } public Object getRhs() { @@ -240,11 +243,11 @@ Object value = this.rhs; if (this.rhs instanceof EntityFunction) { - value = ((EntityFunction) this.rhs).getOriginalValue(); + value = UtilGenerics.<EntityFunction<?>>cast(this.rhs).getOriginalValue(); } if (value instanceof Collection) { - Collection valueCol = (Collection) value; + Collection<?> valueCol = UtilGenerics.cast(value); if (valueCol.size() > 0) { value = valueCol.iterator().next(); } else { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java Wed Nov 18 04:54:18 2009 @@ -27,6 +27,7 @@ import javolution.context.ObjectFactory; import javolution.util.FastMap; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.util.EntityUtil; /** @@ -48,11 +49,11 @@ super(); } - public static List<EntityExpr> makeConditionList(EntityComparisonOperator op, Object... keysValues) { + public static <V> List<EntityExpr> makeConditionList(EntityComparisonOperator<?,V> op, V... keysValues) { return makeConditionList(EntityUtil.makeFields(keysValues), op); } - public static List<EntityExpr> makeConditionList(Map<String, ? extends Object> fieldMap, EntityComparisonOperator op) { + public static <V> List<EntityExpr> makeConditionList(Map<String, V> fieldMap, EntityComparisonOperator<?,V> op) { if (fieldMap == null) return new ArrayList<EntityExpr>(); List<EntityExpr> list = new ArrayList<EntityExpr>(fieldMap.size()); for (Map.Entry<String, ? extends Object> entry: fieldMap.entrySet()) { @@ -64,13 +65,13 @@ /** @deprecated Use EntityCondition.makeCondition() instead */ @Deprecated - public EntityFieldMap(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { + public <L,R,V> EntityFieldMap(EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp, V... keysValues) { this.init(compOp, joinOp, keysValues); } /** @deprecated Use EntityCondition.makeCondition() instead */ @Deprecated - public EntityFieldMap(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { + public <L,R,V> EntityFieldMap(Map<String, V> fieldMap, EntityComparisonOperator<L,R> compOp, EntityJoinOperator joinOp) { this.init(fieldMap, compOp, joinOp); } @@ -86,15 +87,15 @@ this.init(fieldMap, EntityOperator.EQUALS, operator); } - public void init(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { - super.init(makeConditionList(EntityUtil.makeFields(keysValues), compOp), joinOp); + public <V> void init(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues) { + super.init(makeConditionList(EntityUtil.makeFields(keysValues), UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp); this.fieldMap = EntityUtil.makeFields(keysValues); if (this.fieldMap == null) this.fieldMap = FastMap.newInstance(); this.operator = joinOp; } - public void init(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { - super.init(makeConditionList(fieldMap, compOp), joinOp); + public <V> void init(Map<String, V> fieldMap, EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp) { + super.init(makeConditionList(fieldMap, UtilGenerics.<EntityComparisonOperator<String,V>>cast(compOp)), joinOp); this.fieldMap = fieldMap; if (this.fieldMap == null) this.fieldMap = FastMap.newInstance(); this.operator = joinOp; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java Wed Nov 18 04:54:18 2009 @@ -26,7 +26,6 @@ import javolution.lang.Reusable; import javolution.util.FastList; -import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java Wed Nov 18 04:54:18 2009 @@ -25,6 +25,7 @@ import javolution.context.ObjectFactory; import javolution.lang.Reusable; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericModelException; import org.ofbiz.entity.config.DatasourceInfo; @@ -35,7 +36,7 @@ * Encapsulates operations between entities and entity fields. This is a immutable class. * */ -public abstract class EntityFunction<T extends Comparable> extends EntityConditionValue implements Reusable { +public abstract class EntityFunction<T extends Comparable<?>> extends EntityConditionValue implements Reusable { public static interface Fetcher<T> { T getValue(Object value); @@ -247,7 +248,7 @@ @Override public boolean equals(Object obj) { if (!(obj instanceof EntityFunction)) return false; - EntityFunction otherFunc = (EntityFunction) obj; + EntityFunction<?> otherFunc = UtilGenerics.cast(obj); return (this.function == otherFunc.function && (this.nested != null ? nested.equals(otherFunc.nested) : otherFunc.nested == null) && (this.value != null ? value.equals(otherFunc.value) : otherFunc.value == null)); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java Wed Nov 18 04:54:18 2009 @@ -45,14 +45,14 @@ } @Override - public void addSqlValue(StringBuilder sql, ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, boolean compat, Object lhs, Object rhs, DatasourceInfo datasourceInfo) { + public void addSqlValue(StringBuilder sql, ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, boolean compat, EntityCondition lhs, EntityCondition rhs, DatasourceInfo datasourceInfo) { sql.append('('); - sql.append(((EntityCondition) lhs).makeWhereString(modelEntity, entityConditionParams, datasourceInfo)); + sql.append(lhs.makeWhereString(modelEntity, entityConditionParams, datasourceInfo)); sql.append(' '); sql.append(getCode()); sql.append(' '); if (rhs instanceof EntityCondition) { - sql.append(((EntityCondition) rhs).makeWhereString(modelEntity, entityConditionParams, datasourceInfo)); + sql.append(rhs.makeWhereString(modelEntity, entityConditionParams, datasourceInfo)); } else { addValue(sql, null, rhs, entityConditionParams); } @@ -81,7 +81,7 @@ } @Override - public EntityCondition freeze(Object lhs, Object rhs) { + public EntityCondition freeze(EntityCondition lhs, EntityCondition rhs) { return EntityCondition.makeCondition(freeze(lhs), this, freeze(rhs)); } @@ -102,20 +102,17 @@ } @Override - public void visit(EntityConditionVisitor visitor, Object lhs, Object rhs) { - ((EntityCondition) lhs).visit(visitor); + public void visit(EntityConditionVisitor visitor, EntityCondition lhs, EntityCondition rhs) { + lhs.visit(visitor); visitor.visit(rhs); } - @Override - public boolean entityMatches(GenericEntity entity, Object lhs, Object rhs) { - return entityMatches(entity, (EntityCondition) lhs, (EntityCondition) rhs); - } - + public Boolean eval(GenericEntity entity, EntityCondition lhs, EntityCondition rhs) { return entityMatches(entity, lhs, rhs) ? Boolean.TRUE : Boolean.FALSE; } - + + @Override public boolean entityMatches(GenericEntity entity, EntityCondition lhs, EntityCondition rhs) { if (lhs.entityMatches(entity) == shortCircuitValue) return shortCircuitValue; if (rhs.entityMatches(entity) == shortCircuitValue) return shortCircuitValue; @@ -126,14 +123,14 @@ return mapMatches(entity.getDelegator(), entity, conditionList); } - public Boolean eval(Delegator delegator, Map<String, ? extends Object> map, Object lhs, Object rhs) { + public Boolean eval(Delegator delegator, Map<String, ? extends Object> map, EntityCondition lhs, EntityCondition rhs) { return castBoolean(mapMatches(delegator, map, lhs, rhs)); } @Override - public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, Object lhs, Object rhs) { - if (((EntityCondition) lhs).mapMatches(delegator, map) == shortCircuitValue) return shortCircuitValue; - if (((EntityCondition) rhs).mapMatches(delegator, map) == shortCircuitValue) return shortCircuitValue; + public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, EntityCondition lhs, EntityCondition rhs) { + if (lhs.mapMatches(delegator, map) == shortCircuitValue) return shortCircuitValue; + if (rhs.mapMatches(delegator, map) == shortCircuitValue) return shortCircuitValue; return !shortCircuitValue; } @@ -151,10 +148,6 @@ } @Override - public void validateSql(ModelEntity modelEntity, Object lhs, Object rhs) throws GenericModelException { - validateSql(modelEntity, (EntityCondition) lhs, (EntityCondition) rhs); - } - public void validateSql(ModelEntity modelEntity, EntityCondition lhs, EntityCondition rhs) throws GenericModelException { lhs.checkCondition(modelEntity); rhs.checkCondition(modelEntity); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java Wed Nov 18 04:54:18 2009 @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericModelException; @@ -53,40 +54,40 @@ public static final int ID_NOT_IN = 13; public static final int ID_NOT_LIKE = 14; - private static HashMap<String, EntityOperator> registry = new HashMap<String, EntityOperator>(); + private static HashMap<String, EntityOperator<?,?,?>> registry = new HashMap<String, EntityOperator<?,?,?>>(); - private static void registerCase(String name, EntityOperator operator) { + private static <L,R,T> void registerCase(String name, EntityOperator<L,R,T> operator) { registry.put(name.toLowerCase(), operator); registry.put(name.toUpperCase(), operator); } - private static void register(String name, EntityOperator operator) { + private static <L,R,T> void register(String name, EntityOperator<L,R,T> operator) { registerCase(name, operator); registerCase(name.replaceAll("-", "_"), operator); registerCase(name.replaceAll("_", "-"), operator); } - public static EntityOperator lookup(String name) { - return registry.get(name); + public static <L,R,T> EntityOperator<L,R,T> lookup(String name) { + return UtilGenerics.cast(registry.get(name)); } - public static EntityComparisonOperator lookupComparison(String name) { - EntityOperator operator = lookup(name); + public static <L,R> EntityComparisonOperator<L,R> lookupComparison(String name) { + EntityOperator<?,?,Boolean> operator = lookup(name); if (!(operator instanceof EntityComparisonOperator)) throw new IllegalArgumentException(name + " is not a comparison operator"); - return (EntityComparisonOperator)operator; + return UtilGenerics.cast(operator); } public static EntityJoinOperator lookupJoin(String name) { - EntityOperator operator = lookup(name); + EntityOperator<?,?,Boolean> operator = lookup(name); if (!(operator instanceof EntityJoinOperator)) throw new IllegalArgumentException(name + " is not a join operator"); - return (EntityJoinOperator)operator; + return UtilGenerics.cast(operator); } - public static final EntityComparisonOperator EQUALS = new ComparableEntityComparisonOperator(ID_EQUALS, "=") { + public static final EntityComparisonOperator<?,?> EQUALS = new ComparableEntityComparisonOperator<Object>(ID_EQUALS, "=") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareEqual(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareEqual(lhs, rhs); } @Override protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { if (rhs == null || rhs == GenericEntity.NULL_FIELD) { @@ -100,9 +101,9 @@ }; static { register("equals", EQUALS); } static { register("=", EQUALS); } - public static final EntityComparisonOperator NOT_EQUAL = new ComparableEntityComparisonOperator(ID_NOT_EQUAL, "<>") { + public static final EntityComparisonOperator<?,?> NOT_EQUAL = new ComparableEntityComparisonOperator<Object>(ID_NOT_EQUAL, "<>") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareNotEqual(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareNotEqual(lhs, rhs); } @Override protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { if (rhs == null || rhs == GenericEntity.NULL_FIELD) { @@ -117,53 +118,53 @@ static { register("notEqual", NOT_EQUAL); } static { register("!=", NOT_EQUAL); } static { register("<>", NOT_EQUAL); } - public static final EntityComparisonOperator LESS_THAN = new ComparableEntityComparisonOperator(ID_LESS_THAN, "<") { + public static final EntityComparisonOperator<?,?> LESS_THAN = new ComparableEntityComparisonOperator<Object>(ID_LESS_THAN, "<") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareLessThan(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareLessThan(lhs, rhs); } }; static { register("less", LESS_THAN); } static { register("less-than", LESS_THAN); } static { register("lessThan", LESS_THAN); } static { register("<", LESS_THAN); } - public static final EntityComparisonOperator GREATER_THAN = new ComparableEntityComparisonOperator(ID_GREATER_THAN, ">") { + public static final EntityComparisonOperator<?,?> GREATER_THAN = new ComparableEntityComparisonOperator<Object>(ID_GREATER_THAN, ">") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThan(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThan(lhs, rhs); } }; static { register("greater", GREATER_THAN); } static { register("greater-than", GREATER_THAN); } static { register("greaterThan", GREATER_THAN); } static { register(">", GREATER_THAN); } - public static final EntityComparisonOperator LESS_THAN_EQUAL_TO = new ComparableEntityComparisonOperator(ID_LESS_THAN_EQUAL_TO, "<=") { + public static final EntityComparisonOperator<?,?> LESS_THAN_EQUAL_TO = new ComparableEntityComparisonOperator<Object>(ID_LESS_THAN_EQUAL_TO, "<=") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareLessThanEqualTo(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareLessThanEqualTo(lhs, rhs); } }; static { register("less-equals", LESS_THAN_EQUAL_TO); } static { register("less-than-equal-to", LESS_THAN_EQUAL_TO); } static { register("lessThanEqualTo", LESS_THAN_EQUAL_TO); } static { register("<=", LESS_THAN_EQUAL_TO); } - public static final EntityComparisonOperator GREATER_THAN_EQUAL_TO = new ComparableEntityComparisonOperator(ID_GREATER_THAN_EQUAL_TO, ">=") { + public static final EntityComparisonOperator<?,?> GREATER_THAN_EQUAL_TO = new ComparableEntityComparisonOperator<Object>(ID_GREATER_THAN_EQUAL_TO, ">=") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThanEqualTo(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThanEqualTo(lhs, rhs); } }; static { register("greater-equals", GREATER_THAN_EQUAL_TO); } static { register("greater-than-equal-to", GREATER_THAN_EQUAL_TO); } static { register("greaterThanEqualTo", GREATER_THAN_EQUAL_TO); } static { register(">=", GREATER_THAN_EQUAL_TO); } - public static final EntityComparisonOperator IN = new CollectionEntityComparisonOperator(ID_IN, "IN") { + public static final EntityComparisonOperator<?,?> IN = new CollectionEntityComparisonOperator<Object>(ID_IN, "IN") { @Override - public boolean compare(Comparable lhs, Collection<Comparable> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); } @Override - protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); } + protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Collection<Comparable<Object>> rhs, DatasourceInfo datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); } }; static { register("in", IN); } - public static final EntityComparisonOperator BETWEEN = new CollectionEntityComparisonOperator(ID_BETWEEN, "BETWEEN") { + public static final EntityComparisonOperator<?,?> BETWEEN = new CollectionEntityComparisonOperator<Object>(ID_BETWEEN, "BETWEEN") { @Override - public boolean compare(Comparable lhs, Collection<Comparable> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); } @Override - protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSBetweenList(entityConditionParams, sb, field, rhs); } + protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Collection<Comparable<Object>> rhs, DatasourceInfo datasourceInfo) { appendRHSBetweenList(entityConditionParams, sb, field, rhs); } }; static { register("between", BETWEEN); } - public static final EntityComparisonOperator NOT = new EntityComparisonOperator<Object, EntityCondition>(ID_NOT, "NOT") { + public static final EntityComparisonOperator<?,?> NOT = new EntityComparisonOperator<Object, EntityCondition>(ID_NOT, "NOT") { @Override public boolean compare(Object lhs, EntityCondition rhs) { throw new UnsupportedOperationException(); } }; @@ -172,21 +173,21 @@ static { register("and", AND); } public static final EntityJoinOperator OR = new EntityJoinOperator(ID_OR, "OR", true); static { register("or", OR); } - public static final EntityComparisonOperator LIKE = new ComparableEntityComparisonOperator(ID_LIKE, "LIKE") { + public static final EntityComparisonOperator<?,?> LIKE = new ComparableEntityComparisonOperator<Object>(ID_LIKE, "LIKE") { @Override - public boolean compare(Comparable lhs, Object rhs) { return EntityComparisonOperator.compareLike(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareLike(lhs, rhs); } }; static { register("like", LIKE); } - public static final EntityComparisonOperator NOT_LIKE = new ComparableEntityComparisonOperator(ID_NOT_LIKE, "NOT LIKE") { + public static final EntityComparisonOperator<?,?> NOT_LIKE = new ComparableEntityComparisonOperator<Object>(ID_NOT_LIKE, "NOT LIKE") { @Override - public boolean compare(Comparable lhs, Object rhs) { return !EntityComparisonOperator.compareLike(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Object rhs) { return !EntityComparisonOperator.compareLike(lhs, rhs); } }; static { register("not-like", NOT_LIKE); } - public static final EntityComparisonOperator NOT_IN = new CollectionEntityComparisonOperator(ID_NOT_IN, "NOT IN") { + public static final EntityComparisonOperator<?,?> NOT_IN = new CollectionEntityComparisonOperator<Object>(ID_NOT_IN, "NOT IN") { @Override - public boolean compare(Comparable lhs, Collection<Comparable> rhs) { return !EntityComparisonOperator.compareIn(lhs, rhs); } + public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) { return !EntityComparisonOperator.compareIn(lhs, rhs); } @Override - protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, DatasourceInfo datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); } + protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Collection<Comparable<Object>> rhs, DatasourceInfo datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); } }; static { register("not-in", NOT_IN); } @@ -223,19 +224,25 @@ // FIXME: CCE @Override public boolean equals(Object obj) { - EntityOperator otherOper = (EntityOperator) obj; - return this.idInt == otherOper.idInt; + if (this == obj) { + return true; + } + if (obj instanceof EntityOperator) { + EntityOperator<?,?,?> otherOper = UtilGenerics.cast(obj); + return this.idInt == otherOper.idInt; + } + return false; } - public boolean entityMatches(GenericEntity entity, Object lhs, Object rhs) { + public boolean entityMatches(GenericEntity entity, L lhs, R rhs) { return mapMatches(entity.getDelegator(), entity, lhs, rhs); } - protected void appendRHSList(List<EntityConditionParam> entityConditionParams, StringBuilder whereStringBuilder, ModelField field, Object rhs) { + protected void appendRHSList(List<EntityConditionParam> entityConditionParams, StringBuilder whereStringBuilder, ModelField field, R rhs) { whereStringBuilder.append('('); if (rhs instanceof Collection) { - Iterator rhsIter = ((Collection) rhs).iterator(); + Iterator<R> rhsIter = UtilGenerics.<Collection<R>>cast(rhs).iterator(); while (rhsIter.hasNext()) { Object inObj = rhsIter.next(); @@ -251,9 +258,9 @@ whereStringBuilder.append(')'); } - protected void appendRHSBetweenList(List<EntityConditionParam> entityConditionParams, StringBuilder whereStringBuilder, ModelField field, Object rhs) { + protected <X> void appendRHSBetweenList(List<EntityConditionParam> entityConditionParams, StringBuilder whereStringBuilder, ModelField field, X rhs) { if (rhs instanceof Collection) { - Iterator rhsIter = ((Collection) rhs).iterator(); + Iterator<R> rhsIter = UtilGenerics.<Collection<R>>cast(rhs).iterator(); while (rhsIter.hasNext()) { Object inObj = rhsIter.next(); @@ -273,17 +280,17 @@ } */ - public abstract boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, Object lhs, Object rhs); - public abstract void validateSql(ModelEntity entity, Object lhs, Object rhs) throws GenericModelException; - public void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, Object lhs, Object rhs, DatasourceInfo datasourceInfo) { + public abstract boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map, L lhs, R rhs); + public abstract void validateSql(ModelEntity entity, L lhs, R rhs) throws GenericModelException; + public void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, L lhs, R rhs, DatasourceInfo datasourceInfo) { addSqlValue(sql, entity, entityConditionParams, true, lhs, rhs, datasourceInfo); } - public abstract void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, boolean compat, Object rhs, Object lhs, DatasourceInfo datasourceInfo); - public abstract EntityCondition freeze(Object lhs, Object rhs); - public abstract void visit(EntityConditionVisitor visitor, Object lhs, Object rhs); + public abstract void addSqlValue(StringBuilder sql, ModelEntity entity, List<EntityConditionParam> entityConditionParams, boolean compat, L lhs, R rhs, DatasourceInfo datasourceInfo); + public abstract EntityCondition freeze(L lhs, R rhs); + public abstract void visit(EntityConditionVisitor visitor, L lhs, R rhs); - public static final Comparable WILDCARD = new Comparable() { + public static final Comparable<?> WILDCARD = new Comparable<Object>() { public int compareTo(Object obj) { if (obj != WILDCARD) throw new ClassCastException(); return 0; @@ -295,13 +302,13 @@ } }; - public static abstract class CollectionEntityComparisonOperator extends EntityComparisonOperator<Comparable, Collection<Comparable>> { + public static abstract class CollectionEntityComparisonOperator<E> extends EntityComparisonOperator<Comparable<E>, Collection<Comparable<E>>> { public CollectionEntityComparisonOperator(int id, String code) { super(id, code); } } - public static abstract class ComparableEntityComparisonOperator extends EntityComparisonOperator<Comparable, Object> { + public static abstract class ComparableEntityComparisonOperator<E> extends EntityComparisonOperator<Comparable<E>, E> { public ComparableEntityComparisonOperator(int id, String code) { super(id, code); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java Wed Nov 18 04:54:18 2009 @@ -20,10 +20,8 @@ package org.ofbiz.entity.condition; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import org.ofbiz.entity.GenericEntity; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/DatasourceInfo.java Wed Nov 18 04:54:18 2009 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.entity.config; -import java.util.LinkedList; import java.util.List; import org.ofbiz.base.util.Debug; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java Wed Nov 18 04:54:18 2009 @@ -18,8 +18,6 @@ *******************************************************************************/ package org.ofbiz.entity.config; -import java.util.Iterator; -import java.util.List; import java.util.Map; import javolution.util.FastMap; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java Wed Nov 18 04:54:18 2009 @@ -21,13 +21,13 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.transaction.TransactionFactory; import org.ofbiz.minerva.pool.jdbc.xa.XAPoolDataSource; @@ -123,13 +123,13 @@ } // static methods for webtools - public static Set getPooledData(String helperName) throws GenericEntityException { + public static <X> Set<X> getPooledData(String helperName) throws GenericEntityException { XAPoolDataSource pds = dsCache.get(helperName); if (pds == null) { Debug.logError("No pool found for helper name [" + helperName + "]", module); - return new HashSet(); + return new HashSet<X>(); } else { - return pds.getPooledObjectRecords(0); // 0 to return all (in use and waiting) + return UtilGenerics.cast(pds.getPooledObjectRecords(0)); // 0 to return all (in use and waiting) } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperDAO.java Wed Nov 18 04:54:18 2009 @@ -19,7 +19,6 @@ package org.ofbiz.entity.datasource; import java.util.Collection; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java Wed Nov 18 04:54:18 2009 @@ -67,7 +67,7 @@ Class<?>[] paramTypes = new Class<?>[] {String.class}; Object[] params = new Object[] {helperName}; - java.lang.reflect.Constructor helperConstructor = null; + java.lang.reflect.Constructor<?> helperConstructor = null; if (helperClass != null) { try { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java Wed Nov 18 04:54:18 2009 @@ -125,10 +125,10 @@ return 0; } - Iterator it = entityCache.values().iterator(); + Iterator<GenericValue> it = entityCache.values().iterator(); int count = 0; while (it.hasNext()) { - GenericValue value = (GenericValue) it.next(); + GenericValue value = it.next(); if (condition.entityMatches(value)) { it.remove(); count++; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java Wed Nov 18 04:54:18 2009 @@ -34,6 +34,7 @@ import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; @@ -192,7 +193,7 @@ } String operatorName = operatorExdr.expandString(context); - EntityOperator operator = EntityOperator.lookup(operatorName); + EntityOperator<?,?,?> operator = EntityOperator.lookup(operatorName); if (operator == null) { throw new IllegalArgumentException("Could not find an entity operator for the name: " + operatorName); } @@ -240,21 +241,21 @@ // this makes more sense logically, but if anyone ever needs it to not behave this way we should add an "or-null" attribute that is true by default if (ignoreCase) { return EntityCondition.makeCondition( - EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), (EntityComparisonOperator) operator, EntityFunction.UPPER(value)), + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), EntityFunction.UPPER(value)), EntityOperator.OR, EntityCondition.makeCondition(fieldName, EntityOperator.EQUALS, null)); } else { return EntityCondition.makeCondition( - EntityCondition.makeCondition(fieldName, (EntityComparisonOperator) operator, value), + EntityCondition.makeCondition(fieldName, UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), value), EntityOperator.OR, EntityCondition.makeCondition(fieldName, EntityOperator.EQUALS, null)); } } else { if (ignoreCase) { // use the stuff to upper case both sides - return EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), (EntityComparisonOperator) operator, EntityFunction.UPPER(value)); + return EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), EntityFunction.UPPER(value)); } else { - return EntityCondition.makeCondition(fieldName, (EntityComparisonOperator) operator, value); + return EntityCondition.makeCondition(fieldName, UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), value); } } } @@ -299,12 +300,12 @@ } String operatorName = combineExdr.expandString(context); - EntityOperator operator = EntityOperator.lookup(operatorName); + EntityOperator<?,?,?> operator = EntityOperator.lookup(operatorName); if (operator == null) { throw new IllegalArgumentException("Could not find an entity operator for the name: " + operatorName); } - return EntityCondition.makeCondition(entityConditionList, (EntityJoinOperator) operator); + return EntityCondition.makeCondition(entityConditionList, UtilGenerics.<EntityJoinOperator>cast(operator)); } } public static class ConditionObject implements Condition { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java Wed Nov 18 04:54:18 2009 @@ -36,7 +36,6 @@ import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.cache.AbstractCache; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.finder.EntityFinderUtil.GetAll; import org.ofbiz.entity.finder.EntityFinderUtil.LimitRange; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java Wed Nov 18 04:54:18 2009 @@ -93,7 +93,7 @@ if (className == null) { throw new IllegalStateException("Could not find connection factory class name definition"); } - Class cfClass = null; + Class<?> cfClass = null; if (className != null && className.length() > 0) { try { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Wed Nov 18 04:54:18 2009 @@ -231,18 +231,18 @@ } /** Makes a WHERE clause String with "<col name>=?" if not null or "<col name> IS null" if null, all AND separated */ - public static String makeWhereStringFromFields(List modelFields, Map<String, Object> fields, String operator) { + public static String makeWhereStringFromFields(List<ModelField> modelFields, Map<String, Object> fields, String operator) { return makeWhereStringFromFields(modelFields, fields, operator, null); } /** Makes a WHERE clause String with "<col name>=?" if not null or "<col name> IS null" if null, all AND separated */ - public static String makeWhereStringFromFields(List modelFields, Map<String, Object> fields, String operator, List<EntityConditionParam> entityConditionParams) { + public static String makeWhereStringFromFields(List<ModelField> modelFields, Map<String, Object> fields, String operator, List<EntityConditionParam> entityConditionParams) { if (modelFields.size() < 1) { return ""; } StringBuilder returnString = new StringBuilder(); - Iterator iter = modelFields.iterator(); + Iterator<ModelField> iter = modelFields.iterator(); while (iter.hasNext()) { Object item = iter.next(); Object name = null; @@ -862,7 +862,7 @@ break; case 15: - sqlP.setValue((java.util.Collection) fieldValue); + sqlP.setValue(UtilGenerics.<Collection<?>>cast(fieldValue)); break; } } catch (GenericNotImplementedException e) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Wed Nov 18 04:54:18 2009 @@ -1420,16 +1420,16 @@ } // append relation elements - Iterator relIter = this.getRelationsIterator(); + Iterator<ModelRelation> relIter = this.getRelationsIterator(); while (relIter != null && relIter.hasNext()) { - ModelRelation rel = (ModelRelation) relIter.next(); + ModelRelation rel = relIter.next(); } // append index elements - Iterator idxIter = this.getIndexesIterator(); + Iterator<ModelIndex> idxIter = this.getIndexesIterator(); while (idxIter != null && idxIter.hasNext()) { - ModelIndex idx = (ModelIndex) idxIter.next(); + ModelIndex idx = idxIter.next(); root.appendChild(idx.toXmlElement(document)); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java Wed Nov 18 04:54:18 2009 @@ -19,8 +19,6 @@ package org.ofbiz.entity.model; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java Wed Nov 18 04:54:18 2009 @@ -362,7 +362,7 @@ String message = "Existing relationship with the same name, but different specs found from what would be auto-created for Entity [" + relatedEnt.getEntityName() + "] ant relationship to entity [" + curModelEntity.getEntityName() + "] title [" + targetTitle + "]; would auto-create: type [" + newRel.getType() + "] and fields [" + newRel.keyMapString(",", "") + "]"; - //Debug.logInfo(message, module); + Debug.logInfo(message, module); } } } else { @@ -539,7 +539,7 @@ if (entityName == null) { return null; } - Set allEntities = this.getEntityNames(); + Set<String> allEntities = this.getEntityNames(); while (!allEntities.contains(entityName) && entityName.length() > 0) { entityName = entityName.substring(1); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Wed Nov 18 04:54:18 2009 @@ -34,6 +34,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -1240,7 +1241,7 @@ } public EntityCondition createCondition(ModelFieldTypeReader modelFieldTypeReader, List<String> entityAliasStack) { - EntityOperator operator = EntityOperator.lookup(this.operator); + EntityOperator<?,?,?> operator = EntityOperator.lookup(this.operator); if (operator == null) { throw new IllegalArgumentException("Could not find an entity operator for the name: " + this.operator); } @@ -1285,21 +1286,21 @@ // this makes more sense logically, but if anyone ever needs it to not behave this way we should add an "or-null" attribute that is true by default if (ignoreCase) { return EntityCondition.makeCondition( - EntityCondition.makeCondition(EntityFunction.UPPER(lhs), (EntityComparisonOperator) operator, EntityFunction.UPPER(rhs)), + EntityCondition.makeCondition(EntityFunction.UPPER(lhs), UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), EntityFunction.UPPER(rhs)), EntityOperator.OR, EntityCondition.makeCondition(lhs, EntityOperator.EQUALS, null)); } else { return EntityCondition.makeCondition( - EntityCondition.makeCondition(lhs, (EntityComparisonOperator) operator, rhs), + EntityCondition.makeCondition(lhs, UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), rhs), EntityOperator.OR, EntityCondition.makeCondition(lhs, EntityOperator.EQUALS, null)); } } else { if (ignoreCase) { // use the stuff to upper case both sides - return EntityCondition.makeCondition(EntityFunction.UPPER(lhs), (EntityComparisonOperator) operator, EntityFunction.UPPER(rhs)); + return EntityCondition.makeCondition(EntityFunction.UPPER(lhs), UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), EntityFunction.UPPER(rhs)); } else { - return EntityCondition.makeCondition(lhs, (EntityComparisonOperator) operator, rhs); + return EntityCondition.makeCondition(lhs, UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), rhs); } } } @@ -1343,12 +1344,12 @@ } } - EntityOperator operator = EntityOperator.lookup(this.combine); + EntityOperator<?,?,?> operator = EntityOperator.lookup(this.combine); if (operator == null) { throw new IllegalArgumentException("Could not find an entity operator for the name: " + operator); } - return EntityCondition.makeCondition(entityConditionList, (EntityJoinOperator) operator); + return EntityCondition.makeCondition(entityConditionList, UtilGenerics.<EntityJoinOperator>cast(operator)); } } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java Wed Nov 18 04:54:18 2009 @@ -43,6 +43,7 @@ import javax.xml.parsers.ParserConfigurationException; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.Debug; @@ -157,9 +158,9 @@ // if (elementName == null) return serializeCustom(object, document); - Collection value = (Collection) object; + Collection<?> value = UtilGenerics.cast(object); Element element = document.createElement(elementName); - Iterator iter = value.iterator(); + Iterator<?> iter = value.iterator(); while (iter.hasNext()) { element.appendChild(serializeSingle(iter.next(), document)); @@ -195,11 +196,11 @@ } Element element = document.createElement(elementName); - Map value = (Map) object; - Iterator iter = value.entrySet().iterator(); + Map<?,?> value = UtilGenerics.cast(object); + Iterator<Map.Entry<?, ?>> iter = UtilGenerics.cast(value.entrySet().iterator()); while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + Map.Entry<?,?> entry = iter.next(); Element entryElement = document.createElement("map-Entry"); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?rev=881669&r1=881668&r2=881669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Wed Nov 18 04:54:18 2009 @@ -131,6 +131,7 @@ GenericValue v = delegator.create("TestingNode", "testingNodeId", nextSeqId, "primaryParentNodeId", root.get("testingNodeId"), "description", "node-level #1"); + assertNotNull(v); } long created = level1; |
Free forum by Nabble | Edit this page |