01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.services.persondir.support.merger;
07:
08: import java.util.Map;
09:
10: /**
11: * Attribute merge strategy whereby considered attributes over-write
12: * previously set values for attributes with colliding names.
13: * @author andrew.petro@yale.edu
14: * @version $Revision: 35128 $ $Date: 2004-12-13 16:27:49 -0700 (Mon, 13 Dec 2004) $
15: */
16: public class ReplacingAttributeAdder implements IAttributeMerger {
17:
18: /**
19: * Simply puts all the values in toConsider into toModify and returns toModify.
20: * This means that for keys in both toConsider and toModify, the
21: * value in toConsider will be controlling.
22: * @param toModify - the Map we are to modify
23: * @param toConsider - the Map we are to consider in modifying toModify
24: * @return the result of toModify.putAll(toConsider)
25: */
26: public Map mergeAttributes(Map toModify, Map toConsider) {
27: if (toModify == null)
28: throw new IllegalArgumentException(
29: "toModify illegally null");
30: if (toConsider == null)
31: throw new IllegalArgumentException(
32: "toConsider illegally null");
33:
34: toModify.putAll(toConsider);
35: return toModify;
36: }
37: }
|