[Building Sakai] Java Help - Builder Pattern and Setters

Charles Severance csev at umich.edu
Sun Aug 11 06:48:39 PDT 2013


Hi all, 

I have a Java question.  

I would like to use a builder pattern for my JSON stuff for LTI 2.0 in Sakai.  One of the things that I need to do is make all my setters return the instance.  So instead of:

public void setThing(String thing) {
  this.thing = thing;
}

I need to do something like this:

public Stuff public void setThing(String thing) {
  this.thing = thing;
  return this;
}

My question is whether switching the return value from void to an instance, do I break all the other things in the world that look for Setters?

Thanks.

/Chuck

P.S. I still hate setters and getters  - but the builder pattern is warming on me because of its type checking and being a little more self-documenting than massive constructors with seven String parameters.


More information about the sakai-dev mailing list