1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.common.util.spring;
17  
18  import java.util.Map;
19  
20  import org.kuali.common.util.Assert;
21  import org.springframework.beans.factory.FactoryBean;
22  import org.springframework.beans.factory.InitializingBean;
23  
24  
25  
26  
27  public class AddToMapFactoryBean<K, V> implements FactoryBean<Map<K, V>>, InitializingBean {
28  
29  	Map<K, V> source;
30  	Map<K, V> target;
31  
32  	@Override
33  	public void afterPropertiesSet() throws Exception {
34  		Assert.notNull(source, "source is null");
35  		Assert.notNull(target, "target is null");
36  		target.putAll(source);
37  	}
38  
39  	@Override
40  	public Map<K, V> getObject() throws Exception {
41  		return target;
42  	}
43  
44  	@Override
45  	public Class<?> getObjectType() {
46  		return Map.class;
47  	}
48  
49  	@Override
50  	public boolean isSingleton() {
51  		return false;
52  	}
53  
54  	public Map<K, V> getSource() {
55  		return source;
56  	}
57  
58  	public void setSource(Map<K, V> source) {
59  		this.source = source;
60  	}
61  
62  	public Map<K, V> getTarget() {
63  		return target;
64  	}
65  
66  	public void setTarget(Map<K, V> target) {
67  		this.target = target;
68  	}
69  
70  }