/*
- * Copyright 2005 the original author or authors.
- *
+ * Copyright 2005-2010 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
package org.wamblee.persistence.hibernate;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.orm.hibernate3.HibernateTemplate;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-import org.wamblee.persistence.Persistent;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+import org.wamblee.persistence.Persistent;
/**
* Extension of
* List of processed persistent objects.
*
*/
- public static void processMap(Map aPersistent, Map aMerged,
+ public static <Key,Value> void processMap(Map<Key,Value> aPersistent, Map<Key,Value> aMerged,
List<ObjectElem> aProcessed) {
if (aMerged.size() != aPersistent.size()) {
throw new RuntimeException("Sizes differ " + aMerged.size() + " " +
aPersistent.size());
}
- Set keys = aMerged.keySet();
+ Set<Entry<Key,Value>> entries = aMerged.entrySet();
- for (Object key : keys) {
+ for (Entry<Key,Value> entry : entries) {
+ Key key = entry.getKey();
if (!aPersistent.containsKey(key)) {
throw new RuntimeException("Key '" + key + "' not found");
}
- Object mergedValue = aMerged.get(key);
+ Value mergedValue = entry.getValue();
Object persistentValue = aPersistent.get(key);
if (mergedValue instanceof Persistent) {
}
public boolean equals(Object aObj) {
+ if (aObj == null) {
+ return false;
+ }
+ if (!(aObj instanceof ObjectElem)) {
+ return false;
+ }
return ((ObjectElem) aObj).object == object;
}