Reifier { @SuppressWarnings("unchecked") public static <E> Collection<E> reifyCollection(Class<? extends Collection> type) { if (! Collection.class.isAssignableFrom(type)) { throw new BlueprintException("Type is not a Collection: " + type); } if (type.isInterface()) { if (type.isAssignableFrom(LinkedList.class)) { return new LinkedList<E>(); } if (type.isAssignableFrom(TreeSet.class)) { return new TreeSet<E>(); } throw new BlueprintException("Don't know how to reify " + type); } else if (! Modifier.isAbstract(type.getModifiers())) { try { return (Collection<E>) type.newInstance(); } catch (Exception e) { throw new BlueprintException("Failed to reify " + type, e); } } else { throw new BlueprintException("Only interfaces and concrete classes can be reified, " + "but " + type + " was given"); } }  @SuppressWarnings("unchecked") static Collection<E> reifyCollection(Class<? extends Collection> type); static Map<String, E> reifyStringMap();  }
@Test(expectedExceptions = BlueprintException.class) public void wontReifyUnknownInterfaces() { Reifier.reifyCollection(ACollectionInterface.class); }
@Test(expectedExceptions = BlueprintException.class) public void wontReifyAbstractCollectionClasses() { Reifier.reifyCollection(AbstractCollection.class); }