1
2
3
4
5
6 package net.sf.beanrunner.factory.impl;
7
8
9 import java.util.*;
10
11 import net.sf.beanrunner.factory.InstanceFactory;
12
13 public class SingleValueInstanceFactory
14 implements InstanceFactory
15 {
16 private List list = new ArrayList();
17
18 public SingleValueInstanceFactory(Object v)
19 {
20 list.add(v);
21 }
22
23
24
25
26 SingleValueInstanceFactory() {
27
28 }
29
30
31
32
33 void setValue(Object value){
34 list.clear();
35 list.add(value);
36 }
37
38
39 public Iterator iterator()
40 throws Exception
41 {
42 if(list.size() != 1) {
43 throw new IllegalStateException("Must have one and only one value");
44 }
45 return list.iterator();
46 }
47
48 }