can I define setter method to return this rather than void?
Like:
ClassA setItem1() {
return this;
}
ClassA setItem2() {
return this;
}
There is nothing preventing you from providing setter methods which return the target object as a convention in your interface...
However, you must also use the canonical signature for Java Bean Simple Property setter methods (e.g. void setProp(Type t)) or the bean property will not be recognized as writeable by other software which expects that signature.