Author: sebb
Date: Mon Oct 24 18:36:10 2011
New Revision: 1188279
URL: http://svn.apache.org/viewvc?rev=1188279&view=rev
Log:
Simplify code
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java?rev=1188279&r1=1188278&r2=1188279&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
Mon Oct 24 18:36:10 2011
@@ -311,25 +311,24 @@ public abstract class AbstractProperty i
* Given a Map, it converts the Map into a collection of JMeterProperty
* objects, appropriate for a MapProperty object.
*/
- protected Map normalizeMap(Map coll) {
- Map<Object, JMeterProperty> newColl = null;
- for (Map.Entry<?,?> entry : ((Map<?,?>)coll).entrySet()) {
- Object item = entry.getKey();
- Object prop = entry.getValue();
- if (newColl == null) {
- try {
- newColl = coll.getClass().newInstance();
- } catch (Exception e) {
- log.error("Bad collection", e);
- return coll;
- }
+ protected Map<String, JMeterProperty> normalizeMap(Map<String,?> coll) {
+ if (coll.isEmpty()) {
+ @SuppressWarnings("unchecked") // empty collection ok to cast
+ Map<String, JMeterProperty> emptyColl = (Map<String,
JMeterProperty>) coll;
+ return emptyColl;
+ }
+ try {
+ @SuppressWarnings("unchecked") // empty collection
+ Map<String, JMeterProperty> newColl =
coll.getClass().newInstance();
+ for (Map.Entry<String,?> entry : ((Map<String,?>)coll).entrySet())
{
+ String item = entry.getKey();
+ Object prop = entry.getValue();
+ newColl.put(item, convertObject(prop));
}
- newColl.put(item, convertObject(prop));
- }
- if (newColl != null) {
return newColl;
- } else {
- return coll;
+ } catch (Exception e) {// should not happen
+ log.error("Cannot create copy of "+coll.getClass().getName(),e);
+ return null;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]