View Javadoc

1   /*
2    * $Id: GenericBean.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.util.generics;
11  
12  import java.util.ArrayList;
13  import java.util.Collection;
14  import java.util.Collections;
15  import java.util.HashMap;
16  import java.util.HashSet;
17  import java.util.List;
18  import java.util.Map;
19  import java.util.Set;
20  
21  /**
22   * TODO
23   */
24  public class GenericBean<T>
25  {
26  
27      enum CustomEnum
28      {
29  
30          VALUE_1, VALUE_2;
31  
32          public String toString()
33          {
34              return "CustomEnum: " + name();
35          }
36      }
37  
38      private Set<Integer> integerSet;
39  
40      private List<String> resourceList;
41  
42      private List<List<Integer>> listOfLists;
43  
44      private ArrayList<String[]> listOfArrays;
45  
46      private List<Map<Integer, Long>> listOfMaps;
47  
48      private Map plainMap;
49  
50      private Map<Short, Integer> shortMap;
51  
52      private HashMap<Long, ?> longMap;
53  
54      private Map<Number, Collection<? extends Object>> collectionMap;
55  
56      private Map<String, Map<Integer, Long>> mapOfMaps;
57  
58      private Map<Integer, List<Integer>> mapOfLists;
59  
60      private CustomEnum customEnum;
61  
62      private T genericProperty;
63  
64      private List<T> genericListProperty;
65  
66  
67      public GenericBean()
68      {
69      }
70  
71      public GenericBean(Set<Integer> integerSet)
72      {
73          this.integerSet = integerSet;
74      }
75  
76      public GenericBean(Set<Integer> integerSet, List<String> resourceList)
77      {
78          this.integerSet = integerSet;
79          this.resourceList = resourceList;
80      }
81  
82      public GenericBean(HashSet<Integer> integerSet, Map<Short, Integer> shortMap)
83      {
84          this.integerSet = integerSet;
85          this.shortMap = shortMap;
86      }
87  
88      public GenericBean(Map<Short, Integer> shortMap, String resource)
89      {
90          this.shortMap = shortMap;
91          this.resourceList = Collections.singletonList(resource);
92      }
93  
94      public GenericBean(Map plainMap, Map<Short, Integer> shortMap)
95      {
96          this.plainMap = plainMap;
97          this.shortMap = shortMap;
98      }
99  
100     public GenericBean(HashMap<Long, ?> longMap)
101     {
102         this.longMap = longMap;
103     }
104 
105     public GenericBean(boolean someFlag, Map<Number, Collection<? extends Object>> collectionMap)
106     {
107         this.collectionMap = collectionMap;
108     }
109 
110 
111     public Set<Integer> getIntegerSet()
112     {
113         return integerSet;
114     }
115 
116     public void setIntegerSet(Set<Integer> integerSet)
117     {
118         this.integerSet = integerSet;
119     }
120 
121     public List<String> getResourceList()
122     {
123         return resourceList;
124     }
125 
126     public void setResourceList(List<String> resourceList)
127     {
128         this.resourceList = resourceList;
129     }
130 
131     public List<List<Integer>> getListOfLists()
132     {
133         return listOfLists;
134     }
135 
136     public ArrayList<String[]> getListOfArrays()
137     {
138         return listOfArrays;
139     }
140 
141     public void setListOfArrays(ArrayList<String[]> listOfArrays)
142     {
143         this.listOfArrays = listOfArrays;
144     }
145 
146     public void setListOfLists(List<List<Integer>> listOfLists)
147     {
148         this.listOfLists = listOfLists;
149     }
150 
151     public List<Map<Integer, Long>> getListOfMaps()
152     {
153         return listOfMaps;
154     }
155 
156     public void setListOfMaps(List<Map<Integer, Long>> listOfMaps)
157     {
158         this.listOfMaps = listOfMaps;
159     }
160 
161     public Map getPlainMap()
162     {
163         return plainMap;
164     }
165 
166     public Map<Short, Integer> getShortMap()
167     {
168         return shortMap;
169     }
170 
171     public void setShortMap(Map<Short, Integer> shortMap)
172     {
173         this.shortMap = shortMap;
174     }
175 
176     public HashMap<Long, ?> getLongMap()
177     {
178         return longMap;
179     }
180 
181     public void setLongMap(HashMap<Long, ?> longMap)
182     {
183         this.longMap = longMap;
184     }
185 
186     public Map<Number, Collection<? extends Object>> getCollectionMap()
187     {
188         return collectionMap;
189     }
190 
191     public void setCollectionMap(Map<Number, Collection<? extends Object>> collectionMap)
192     {
193         this.collectionMap = collectionMap;
194     }
195 
196     public Map<String, Map<Integer, Long>> getMapOfMaps()
197     {
198         return mapOfMaps;
199     }
200 
201     public void setMapOfMaps(Map<String, Map<Integer, Long>> mapOfMaps)
202     {
203         this.mapOfMaps = mapOfMaps;
204     }
205 
206     public Map<Integer, List<Integer>> getMapOfLists()
207     {
208         return mapOfLists;
209     }
210 
211     public void setMapOfLists(Map<Integer, List<Integer>> mapOfLists)
212     {
213         this.mapOfLists = mapOfLists;
214     }
215 
216     public T getGenericProperty()
217     {
218         return genericProperty;
219     }
220 
221     public void setGenericProperty(T genericProperty)
222     {
223         this.genericProperty = genericProperty;
224     }
225 
226     public List<T> getGenericListProperty()
227     {
228         return genericListProperty;
229     }
230 
231     public void setGenericListProperty(List<T> genericListProperty)
232     {
233         this.genericListProperty = genericListProperty;
234     }
235 
236     public CustomEnum getCustomEnum()
237     {
238         return customEnum;
239     }
240 
241     public void setCustomEnum(CustomEnum customEnum)
242     {
243         this.customEnum = customEnum;
244     }
245 
246 
247     public static GenericBean createInstance(Set<Integer> integerSet)
248     {
249         return new GenericBean(integerSet);
250     }
251 
252     public static GenericBean createInstance(Set<Integer> integerSet, List<String> resourceList)
253     {
254         return new GenericBean(integerSet, resourceList);
255     }
256 
257     public static GenericBean createInstance(HashSet<Integer> integerSet, Map<Short, Integer> shortMap)
258     {
259         return new GenericBean(integerSet, shortMap);
260     }
261 
262     public static GenericBean createInstance(Map<Short, Integer> shortMap, String resource)
263     {
264         return new GenericBean(shortMap, resource);
265     }
266 
267     public static GenericBean createInstance(Map map, Map<Short, Integer> shortMap)
268     {
269         return new GenericBean(map, shortMap);
270     }
271 
272     public static GenericBean createInstance(HashMap<Long, ?> longMap)
273     {
274         return new GenericBean(longMap);
275     }
276 
277     public static GenericBean createInstance(boolean someFlag, Map<Number, Collection<? extends Object>> collectionMap)
278     {
279         return new GenericBean(someFlag, collectionMap);
280     }
281 
282 }