peterlck / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

proposal for new JavaGenerator replacing the XML configuration file #205

Open GoogleCodeExporter opened 10 years ago

GoogleCodeExporter commented 10 years ago
i've always wanted to define the hamcrest matchers configuration in a clean 
java style instead of the (refactoring-unsafe!) XML file. so i came up with the 
following solution (see patch):

**
class SampleHamcrestConfiguration implements HamcrestConfiguration {
  public static void main(String[] args) {
    new JavaGeneratorBuilder()
      .addConfigurations(new SampleHamcrestConfiguration())
      .targetClass("com.foobar.SampleMatchers")
      .build()
      .generate();
  }
  public Collection<Class<?>> matchers() {
    Collection<Class<?>> matcher = new LinkedList<Class<?>>();
    matcher.add(MyMatcher.class);
    return matcher;
  }
}
**

what do you guys think? next step would be to allow a package scan, so new 
custom matchers will be picked up automatically ;)

~christoph

Original issue reported on code.google.com by christop...@gmail.com on 6 Apr 2014 at 2:30

Attachments: