Setters that return the Object
Does the JavaBean specification allow for a bean setter to return the object that it sets a property for? Suppose you had a bean like so:
public class Fish ( ) {
private String color ;
private int length ;
public String getColor ( ) { return color ; }
public Fish setColor ( String color ) {
this.color = color ;
return this ;
}
public int getLength ( ) { return length ; }
public Fish setLength ( int length ) {
this.length = length ;
return this ;
}
}
Then, I could call all of the setters at once:
Fish bailey = new Fish() ;
bailey.setColor("gold").setLength(2) ;
Is this kosher?
Anthony

