01: package org.vraptor.reflection;
02:
03: import java.util.Collection;
04:
05: /**
06: * A set dealer factory.
07: *
08: * @author Guilherme Silveira
09: */
10: public class SetDealerFactory {
11:
12: public static SetDealer getDealer(Object object)
13: throws SettingException {
14: // TODO: optimize for random access where faster implementation is ok
15: if (object.getClass().isArray()) {
16: return new ArrayDealer();
17: } else if (Collection.class.isAssignableFrom(object.getClass())) {
18: return new CollectionDealer();
19: }
20:
21: throw new SettingException("Invalid collection type: "
22: + object.getClass().getName());
23: }
24:
25: }
|