Gets objects of an assignable type. The collection contains objects that are assignable from the class or interface. Returns a shallow clone. @param c the type of object @return the collection
(Class<?> c)
| 120 | * @return the collection |
| 121 | */ |
| 122 | public Collection<Object> getObjects(Class<?> c) { |
| 123 | HashMap<String, Object> map = new HashMap<String, Object>(myObjects); // clone the object map |
| 124 | Iterator<Object> it = map.values().iterator(); |
| 125 | while (it.hasNext()) { // copy only the objects of the correct type |
| 126 | Object obj = it.next(); |
| 127 | if (!c.isInstance(obj)) { |
| 128 | it.remove(); |
| 129 | } |
| 130 | } |
| 131 | return map.values(); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Gets the objects. |