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.Collection;
19 import java.util.List;
20
21 import org.kuali.common.util.Assert;
22 import org.springframework.beans.factory.FactoryBean;
23 import org.springframework.beans.factory.InitializingBean;
24
25
26
27
28 public class AddToListFactoryBean<T> implements FactoryBean<List<T>>, InitializingBean {
29
30 List<T> source;
31 List<T> target;
32
33 @Override
34 public void afterPropertiesSet() throws Exception {
35 Assert.notNull(source, "source is null");
36 Assert.notNull(target, "target is null");
37 target.addAll(source);
38 }
39
40 @Override
41 public List<T> getObject() throws Exception {
42 return target;
43 }
44
45 @Override
46 public Class<?> getObjectType() {
47 return List.class;
48 }
49
50 @Override
51 public boolean isSingleton() {
52 return false;
53 }
54
55 public Collection<T> getSource() {
56 return source;
57 }
58
59 public void setSource(List<T> source) {
60 this.source = source;
61 }
62
63 public Collection<T> getTarget() {
64 return target;
65 }
66
67 public void setTarget(List<T> target) {
68 this.target = target;
69 }
70
71 }