Quantcast
Channel: Jarrod Roberson: Programming Missives » Programming
Viewing all articles
Browse latest Browse all 13

Automatically generating an immutable value object implementation for Interface.

$
0
0

While refining my Type Safe Fluent Builder pattern implementation I wanted a way to materialize an Interface without having to write all the boilerplate code related to value objects and having huge constructors or lots of closure like inner class implementation scoped temporary variables that were not immutable and the like I decided I needed a more dynamic way to build the value object.

I considered using a Guava ImmutableMap with the builder methods and then pass the fully populated map into my constructor but that does not eliminate the boilerplate for the variables and makes maintenance an ongoing problem as well.

I considered writing a Maven plugin to take an annotated Interface and generate the code, but that just moves the problem, I wanted something even more automatic and dynamic.

I decided to try this experiment with Dynamic Proxies and I was pleased with the first result.

And here is the JUnit Test harness.


Viewing all articles
Browse latest Browse all 13

Latest Images

Trending Articles





Latest Images