Esempio n. 1
0
 /** Convert a collection of ConstantSets to the format expected by GenTest.addClassLiterals. */
 public static MultiMap<Class<?>, PrimitiveOrStringOrNullDecl> toMap(
     Collection<ConstantSet> constantSets) {
   final MultiMap<Class<?>, PrimitiveOrStringOrNullDecl> map =
       new MultiMap<Class<?>, PrimitiveOrStringOrNullDecl>();
   for (ConstantSet cs : constantSets) {
     Class<?> clazz;
     try {
       clazz = Class.forName(cs.classname);
     } catch (ClassNotFoundException e) {
       throw new Error("Class " + cs.classname + " not found on the classpath.");
     }
     for (Integer x : cs.ints) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(int.class, x.intValue()));
     }
     for (Long x : cs.longs) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(long.class, x.longValue()));
     }
     for (Float x : cs.floats) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(float.class, x.floatValue()));
     }
     for (Double x : cs.doubles) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(double.class, x.doubleValue()));
     }
     for (String x : cs.strings) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(String.class, x));
     }
     for (Class<?> x : cs.classes) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(Class.class, x));
     }
   }
   return map;
 }