joelittlejohn/jsonschema2pojo — pull request #211 by davidpadbury (2014-06-28 20:45:21+00:00)
Title: Pluggable RuleFactory

As discussed in #210, this request adds supports for specifying a custom RuleFactory enabling consumers to hook in custom rules to modify generation behavior.

Please consider this initial request only an invitation to opine on the approach. Although the implemented behavior and [IT successfully demonstrates](https://github.com/davidpadbury/jsonschema2pojo/blob/61795456c16d8239b5c230b24239c1ec0be05605/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/config/RuleFactoryFactoryIT.java) the extension is possible, I'm rather horrified to have actually used a [FactoryFactory](https://github.com/davidpadbury/jsonschema2pojo/blob/61795456c16d8239b5c230b24239c1ec0be05605/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/RuleFactoryFactory.java).

The problem resides with that current a RuleFactory implementation depends on being passed the [config, annotator, and schema store](https://github.com/joelittlejohn/jsonschema2pojo/blob/master/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jsonschema2Pojo.java#L52). Rather than invoke a particular constructor via reflection that feels awfully messy, I opted for creating something to have an interface with those dependencies and returning a RuleFactory. However we now have our FactoryFactory. I considered naming the thing a "creator" or something, but that seems to skirt around the issue.

What do you think? Is this exposing a design issue, or should we just name something less embarrassing and move on?