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