1 package org.springframework.expression.spel.testresources;
2
3 import java.util.ArrayList;
4 import java.util.Date;
5 import java.util.HashMap;
6 import java.util.LinkedHashMap;
7 import java.util.List;
8 import java.util.Map;
9
10 import org.springframework.util.ObjectUtils;
11
12
13 @SuppressWarnings("unused")
14 public class Inventor {
15 private String name;
16 public String _name;
17 public String _name_;
18 public String publicName;
19 private PlaceOfBirth placeOfBirth;
20 private Date birthdate;
21 private int sinNumber;
22 private String nationality;
23 private String[] inventions;
24 public String randomField;
25 public Map<String,String> testMap;
26 private boolean wonNobelPrize;
27 private PlaceOfBirth[] placesLived;
28 private List<PlaceOfBirth> placesLivedList = new ArrayList<PlaceOfBirth>();
29 public ArrayContainer arrayContainer;
30 public boolean publicBoolean;
31 private boolean accessedThroughGetSet;
32 public List<Integer> listOfInteger = new ArrayList<Integer>();
33 public List<Boolean> booleanList = new ArrayList<Boolean>();
34 public Map<String,Boolean> mapOfStringToBoolean = new LinkedHashMap<String,Boolean>();
35 public Map<Integer,String> mapOfNumbersUpToTen = new LinkedHashMap<Integer,String>();
36 public List<Integer> listOfNumbersUpToTen = new ArrayList<Integer>();
37 public List<Integer> listOneFive = new ArrayList<Integer>();
38 public String[] stringArrayOfThreeItems = new String[]{"1","2","3"};
39 private String foo;
40 public int counter;
41
42 public Inventor(String name, Date birthdate, String nationality) {
43 this.name = name;
44 this._name = name;
45 this._name_ = name;
46 this.birthdate = birthdate;
47 this.nationality = nationality;
48 this.arrayContainer = new ArrayContainer();
49 testMap = new HashMap<String,String>();
50 testMap.put("monday", "montag");
51 testMap.put("tuesday", "dienstag");
52 testMap.put("wednesday", "mittwoch");
53 testMap.put("thursday", "donnerstag");
54 testMap.put("friday", "freitag");
55 testMap.put("saturday", "samstag");
56 testMap.put("sunday", "sonntag");
57 listOneFive.add(1);
58 listOneFive.add(5);
59 booleanList.add(false);
60 booleanList.add(false);
61 listOfNumbersUpToTen.add(1);
62 listOfNumbersUpToTen.add(2);
63 listOfNumbersUpToTen.add(3);
64 listOfNumbersUpToTen.add(4);
65 listOfNumbersUpToTen.add(5);
66 listOfNumbersUpToTen.add(6);
67 listOfNumbersUpToTen.add(7);
68 listOfNumbersUpToTen.add(8);
69 listOfNumbersUpToTen.add(9);
70 listOfNumbersUpToTen.add(10);
71 mapOfNumbersUpToTen.put(1,"one");
72 mapOfNumbersUpToTen.put(2,"two");
73 mapOfNumbersUpToTen.put(3,"three");
74 mapOfNumbersUpToTen.put(4,"four");
75 mapOfNumbersUpToTen.put(5,"five");
76 mapOfNumbersUpToTen.put(6,"six");
77 mapOfNumbersUpToTen.put(7,"seven");
78 mapOfNumbersUpToTen.put(8,"eight");
79 mapOfNumbersUpToTen.put(9,"nine");
80 mapOfNumbersUpToTen.put(10,"ten");
81 }
82
83 public void setPlaceOfBirth(PlaceOfBirth placeOfBirth2) {
84 placeOfBirth = placeOfBirth2;
85 this.placesLived = new PlaceOfBirth[] { placeOfBirth2 };
86 this.placesLivedList.add(placeOfBirth2);
87 }
88
89 public String[] getInventions() {
90 return inventions;
91 }
92
93 public void setInventions(String[] inventions) {
94 this.inventions = inventions;
95 }
96
97 public PlaceOfBirth getPlaceOfBirth() {
98 return placeOfBirth;
99 }
100
101 public int throwException(int valueIn) throws Exception {
102 counter++;
103 if (valueIn==1) {
104 throw new IllegalArgumentException("IllegalArgumentException for 1");
105 }
106 if (valueIn==2) {
107 throw new RuntimeException("RuntimeException for 2");
108 }
109 if (valueIn==4) {
110 throw new TestException();
111 }
112 return valueIn;
113 }
114
115 @SuppressWarnings("serial")
116 static class TestException extends Exception {}
117
118 public String throwException(PlaceOfBirth pob) {
119 return pob.getCity();
120 }
121
122 public String getName() {
123 return name;
124 }
125
126 public boolean getWonNobelPrize() {
127 return wonNobelPrize;
128 }
129
130 public void setWonNobelPrize(boolean wonNobelPrize) {
131 this.wonNobelPrize = wonNobelPrize;
132 }
133
134 public PlaceOfBirth[] getPlacesLived() {
135 return placesLived;
136 }
137
138 public void setPlacesLived(PlaceOfBirth[] placesLived) {
139 this.placesLived = placesLived;
140 }
141
142 public List<PlaceOfBirth> getPlacesLivedList() {
143 return placesLivedList;
144 }
145
146 public void setPlacesLivedList(List<PlaceOfBirth> placesLivedList) {
147 this.placesLivedList = placesLivedList;
148 }
149
150 public String echo(Object o) {
151 return o.toString();
152 }
153
154 public String sayHelloTo(String person) {
155 return "hello " + person;
156 }
157
158 public String printDouble(Double d) {
159 return d.toString();
160 }
161
162 public String printDoubles(double[] d) {
163 return ObjectUtils.nullSafeToString(d);
164 }
165
166 public List<String> getDoublesAsStringList() {
167 List<String> result = new ArrayList<String>();
168 result.add("14.35");
169 result.add("15.45");
170 return result;
171 }
172
173 public String joinThreeStrings(String a, String b, String c) {
174 return a + b + c;
175 }
176
177 public int aVarargsMethod(String... strings) {
178 if (strings == null)
179 return 0;
180 return strings.length;
181 }
182
183 public int aVarargsMethod2(int i, String... strings) {
184 if (strings == null)
185 return i;
186 return strings.length + i;
187 }
188
189 public Inventor(String... strings) {
190
191 }
192
193 public boolean getSomeProperty() {
194 return accessedThroughGetSet;
195 }
196
197 public void setSomeProperty(boolean b) {
198 this.accessedThroughGetSet = b;
199 }
200
201 public Date getBirthdate() { return birthdate;}
202
203 public String getFoo() { return foo; }
204 public void setFoo(String s) { foo = s; }
205
206 public String getNationality() { return nationality; }
207 }