I am trying to create a square with many parameters, using a builder pattern instead of the telescoping constructor. I am doing it in the manner described by Joshua Bloch's influential Java, which has a private producer and public static builder class in the enclosed class. The Builder Class ensures that the object is in a consistent position before making a Building () call, at that point, it assigns the creation of the Private Object to the Personal Producer. Thus
public square fu {// many variables Pure Fu (Builder B) {// Use the variable of all B to initialize itself} Public Fixed Ultimate Category Builder {Public Builder (/ * required variable * /) {} public builder var1 (var var) {// return it; } Public Fu Build () {Return new Fu (this); }}}
Then I want to add type bounds in some variables, and thus the definition of the class is parametridge, I want that the square of the Fu square is the same as the builder class.
Public Square Foo < Q increases quantity & gt; {Private Final Unit & Lt; Q & gt; Units; // Multiple variables Personal Fees (Builder & Lt; Q & gt; B) {// Use All B variables to start yourself} Public Fixed Ultimate Category Builder & lt; Q increases volume & gt; {Private unit & lt; Q & gt; Units; Public Builder (/ * Required Variables * /) {} Public Builder Units (Unit and LT; Q and Unit) {this.units = units; This return; } Public Fu Build () {New Foo & lt; Q & gt; (this); }}}
It compiles fine, but the compiler is allowing me to do what I think should be compiler errors. E.g.
Public Stable Foo.Builder Last The logic of units here is unit and lieutenant; Acceleration & gt;
is not, but the unit & lt; Length & gt;
, but it has still been accepted by the compiler.
Am I doing wrong here? I want to make sure to compile the time that the unit type matches correctly.
entities
builder & lt; Q & gt;
should not be an unchanged builder
.
Comments
Post a Comment