//: net/mindview/util/BasicGenerator.java // Automatically create a Generator, given a class // with a default (no-arg) constructor. package net.mindview.util; public class BasicGenerator implements Generator { private Class type; public BasicGenerator(Class type){ this.type = type; } public T next() { try { // Assumes type is a public class: return type.newInstance(); } catch(Exception e) { throw new RuntimeException(e); } } // Produce a Default generator given a type token: public static Generator create(Class type) { return new BasicGenerator(type); } } ///:~