* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
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;
}