Module openj9.dtfj

Class PHDJavaObject.Builder

java.lang.Object
com.ibm.dtfj.phd.PHDJavaObject.Builder
Enclosing class:
PHDJavaObject

public static class PHDJavaObject.Builder extends Object
The constructors for PHDJavaObject used to take up to 11 arguments, many of which were ints. This made it hard to tie up which argument corresponded to which parameter and invited errors since there can be no type checking.

This is now fixed by the use of the Builder pattern as described in Effective Java Second Edition by Joshua Bloch (http://cyclo.ps/books/Prentice.Hall.Effective.Java.2nd.Edition.May.2008.pdf), item 2 "Consider a builder when faced with many constructor parameters".

The only way to construct a PHDJavaObject is now using this Builder. Required arguments are set with a call to the Builder constructor, then optional arguments are set, then build() is called, usually all in one line using a fluent interface.