You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2013/05/14 01:52:52 UTC
svn commit: r1482152 - in
/ofbiz/trunk/framework/entity/src/org/ofbiz/entity: condition/ connection/
model/
Author: doogie
Date: Mon May 13 23:52:52 2013
New Revision: 1482152
URL: http://svn.apache.org/r1482152
Log:
OPTIMIZE: Remove all SuppressWarnings("unchecked") from the entity
engine.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelField.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelIndex.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java
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=1482152&r1=1482151&r2=1482152&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 Mon May 13 23:52:52 2013
@@ -43,11 +43,11 @@ import org.ofbiz.entity.model.ModelViewE
* These can be used in various combinations using the EntityConditionList and EntityExpr objects.
*
*/
-@SuppressWarnings({ "serial", "unchecked" })
+@SuppressWarnings("serial")
public abstract class EntityConditionBase implements Serializable {
- public static final List<?> emptyList = Collections.unmodifiableList(new ArrayList(0));
- public static final Map<?,?> _emptyMap = Collections.unmodifiableMap(new HashMap());
+ public static final List<?> emptyList = Collections.emptyList();
+ public static final Map<?,?> _emptyMap = Collections.emptyMap();
public static final Map<String, String> emptyAliases = Collections.unmodifiableMap(new HashMap<String, String>());
protected ModelField getField(ModelEntity modelEntity, String fieldName) {
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java?rev=1482152&r1=1482151&r2=1482152&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBuilder.java Mon May 13 23:52:52 2013
@@ -45,7 +45,6 @@ public class EntityConditionBuilder exte
return node;
}
- @SuppressWarnings("unchecked")
@Override
protected Object createNode(Object methodName, Map mapArg) {
Map<String, Object> fieldValueMap = UtilGenerics.checkMap(mapArg);
@@ -62,7 +61,6 @@ public class EntityConditionBuilder exte
}
}
- @SuppressWarnings("unchecked")
@Override
protected Object createNode(Object methodName, Map mapArg, Object objArg) {
return null;
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1482152&r1=1482151&r2=1482152&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Mon May 13 23:52:52 2013
@@ -176,9 +176,8 @@ public class DBCPConnectionFactory imple
dsCache.clear();
}
- @SuppressWarnings("unchecked")
- public static Map getDataSourceInfo(String helperName) {
- Map dataSourceInfo = new HashMap();
+ public static Map<String, Object> getDataSourceInfo(String helperName) {
+ Map<String, Object> dataSourceInfo = new HashMap<String, Object>();
ManagedDataSource mds = dsCache.get(helperName);
if (mds instanceof DebugManagedDataSource) {
dataSourceInfo = ((DebugManagedDataSource)mds).getInfo();
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java?rev=1482152&r1=1482151&r2=1482152&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java Mon May 13 23:52:52 2013
@@ -55,8 +55,8 @@ public class DebugManagedDataSource exte
return super.getConnection();
}
- public Map getInfo() {
- Map dataSourceInfo = new HashMap();
+ public Map<String, Object> getInfo() {
+ Map<String, Object> dataSourceInfo = new HashMap<String, Object>();
dataSourceInfo.put("poolNumActive", super._pool.getNumActive());
dataSourceInfo.put("poolNumIdle", super._pool.getNumIdle());
dataSourceInfo.put("poolNumTotal", (super._pool.getNumIdle() + super._pool.getNumActive()));
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=1482152&r1=1482151&r2=1482152&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 Mon May 13 23:52:52 2013
@@ -58,7 +58,6 @@ import org.w3c.dom.Element;
* An object that models the <code><entity></code> element.
*
*/
-@SuppressWarnings("serial")
public class ModelEntity implements Comparable<ModelEntity>, Serializable {
public static final String module = ModelEntity.class.getName();
@@ -540,10 +539,9 @@ public class ModelEntity implements Comp
return getPkFields().iterator();
}
- @SuppressWarnings("unchecked")
public List<ModelField> getPkFields() {
synchronized (fieldsLock) {
- return (List) this.pks.clone();
+ return new ArrayList<ModelField>(this.pks);
}
}
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelField.java?rev=1482152&r1=1482151&r2=1482152&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelField.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelField.java Mon May 13 23:52:52 2013
@@ -66,7 +66,6 @@ public final class ModelField extends Mo
* @param enableAuditLog <code>true</code> if this field is included in the entity audit log.
* @param validators The validators for this field.
*/
- @SuppressWarnings("unchecked")
public static ModelField create(ModelEntity modelEntity, String description, String name, String type, String colName, String colValue, String fieldSet, boolean isNotNull, boolean isPk, boolean encrypt, boolean isAutoCreatedInternal, boolean enableAuditLog, List<String> validators) {
// TODO: Validate parameters.
if (description == null) {
@@ -88,7 +87,7 @@ public final class ModelField extends Mo
fieldSet = "";
}
if (validators == null) {
- validators = Collections.EMPTY_LIST;
+ validators = Collections.emptyList();
} else {
validators = Collections.unmodifiableList(validators);
}
@@ -105,7 +104,6 @@ public final class ModelField extends Mo
* @param fieldElement The <code><field></code> element containing the values for this field.
* @param isPk <code>true</code> if this field is part of the primary key.
*/
- @SuppressWarnings("unchecked")
public static ModelField create(ModelEntity modelEntity, Element fieldElement, boolean isPk) {
String description = UtilXml.childElementValue(fieldElement, "description");
if (description == null) {
@@ -125,7 +123,7 @@ public final class ModelField extends Mo
}
boolean encrypt = "true".equals(fieldElement.getAttribute("encrypt"));
boolean enableAuditLog = "true".equals(fieldElement.getAttribute("enable-audit-log"));
- List<String>validators = Collections.EMPTY_LIST;
+ List<String>validators = Collections.emptyList();
List<? extends Element> elementList = UtilXml.childElementList(fieldElement, "validate");
if (!elementList.isEmpty()) {
validators = new ArrayList<String>(elementList.size());
@@ -144,7 +142,6 @@ public final class ModelField extends Mo
* @param ccInfo The <code>ColumnCheckInfo</code> containing the values for this field.
* @param modelFieldTypeReader
*/
- @SuppressWarnings("unchecked")
public static ModelField create(ModelEntity modelEntity, DatabaseUtil.ColumnCheckInfo ccInfo, ModelFieldTypeReader modelFieldTypeReader) {
String colName = ccInfo.columnName;
String name = ModelUtil.dbNameToVarName(colName);
@@ -156,7 +153,7 @@ public final class ModelField extends Mo
String fieldSet = "";
boolean encrypt = false;
boolean enableAuditLog = false;
- return new ModelField(modelEntity, description, name, type, colName, colValue, fieldSet, isNotNull, isPk, encrypt, false, enableAuditLog, Collections.EMPTY_LIST);
+ return new ModelField(modelEntity, description, name, type, colName, colValue, fieldSet, isNotNull, isPk, encrypt, false, enableAuditLog, Collections.<String>emptyList());
}
/*
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelIndex.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelIndex.java?rev=1482152&r1=1482151&r2=1482152&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelIndex.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelIndex.java Mon May 13 23:52:52 2013
@@ -45,7 +45,6 @@ public final class ModelIndex extends Mo
* @param fields The fields that are included in this index.
* @param unique <code>true</code> if this index returns unique values.
*/
- @SuppressWarnings("unchecked")
public static ModelIndex create(ModelEntity modelEntity, String description, String name, List<Field> fields, boolean unique) {
if (description == null) {
description = "";
@@ -54,7 +53,7 @@ public final class ModelIndex extends Mo
name = "";
}
if (fields == null) {
- fields = Collections.EMPTY_LIST;
+ fields = Collections.emptyList();
} else {
fields = Collections.unmodifiableList(fields);
}
@@ -67,12 +66,11 @@ public final class ModelIndex extends Mo
* @param modelEntity The <code>ModelEntity</code> this index is a member of.
* @param indexElement The <code><index></code> element containing the values for this index.
*/
- @SuppressWarnings("unchecked")
public static ModelIndex create(ModelEntity modelEntity, Element indexElement) {
String name = indexElement.getAttribute("name").intern();
boolean unique = "true".equals(indexElement.getAttribute("unique"));
String description = UtilXml.childElementValue(indexElement, "description");
- List<Field>fields = Collections.EMPTY_LIST;
+ List<Field>fields = Collections.emptyList();
List<? extends Element> elementList = UtilXml.childElementList(indexElement, "index-field");
if (!elementList.isEmpty()) {
fields = new ArrayList<Field>(elementList.size());
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java?rev=1482152&r1=1482151&r2=1482152&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java Mon May 13 23:52:52 2013
@@ -51,7 +51,6 @@ public final class ModelRelation extends
* @param keyMaps The key maps included in this relation.
* @param isAutoRelation <code>true</code> if this relation was generated automatically by the entity engine.
*/
- @SuppressWarnings("unchecked")
public static ModelRelation create(ModelEntity modelEntity, String description, String type, String title, String relEntityName, String fkName, List<ModelKeyMap> keyMaps, boolean isAutoRelation) {
if (description == null) {
description = "";
@@ -69,7 +68,7 @@ public final class ModelRelation extends
fkName = "";
}
if (keyMaps == null) {
- keyMaps = Collections.EMPTY_LIST;
+ keyMaps = Collections.emptyList();
} else {
keyMaps = Collections.unmodifiableList(keyMaps);
}
@@ -83,14 +82,13 @@ public final class ModelRelation extends
* @param relationElement The <code><relation></code> element containing the values for this relation.
* @param isAutoRelation <code>true</code> if this relation was generated automatically by the entity engine.
*/
- @SuppressWarnings("unchecked")
public static ModelRelation create(ModelEntity modelEntity, Element relationElement, boolean isAutoRelation) {
String type = relationElement.getAttribute("type").intern();
String title = relationElement.getAttribute("title").intern();
String relEntityName = relationElement.getAttribute("rel-entity-name").intern();
String fkName = relationElement.getAttribute("fk-name").intern();
String description = UtilXml.childElementValue(relationElement, "description");
- List<ModelKeyMap >keyMaps = Collections.EMPTY_LIST;
+ List<ModelKeyMap >keyMaps = Collections.emptyList();
List<? extends Element> elementList = UtilXml.childElementList(relationElement, "key-map");
if (!elementList.isEmpty()) {
keyMaps = new ArrayList<ModelKeyMap>(elementList.size());