Why not @Setter return this so I can call it cascadely

310 views
Skip to first unread message

limbo

unread,
Jan 18, 2018, 11:20:21 AM1/18/18
to Project Lombok
I mean this plain java bean/POJP seems like this
class Person {
  private Integer age;
  private String name;
  public Person setAge(Integer age) {
    this.age = age;
    return this;
  }
  // ....
}


yawkat

unread,
Jan 19, 2018, 6:15:25 AM1/19/18
to Project Lombok
You can achieve this using @Setter(chain=true)

Martin Grajcar

unread,
Jan 19, 2018, 6:27:00 AM1/19/18
to project...@googlegroups.com
IIRC it's @Accessors(chain=true) @Setter. See also https://projectlombok.org/features/configuration:

lombok.accessors.fluent=true
lombok.accessors.chain=true


--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombok+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roel Spilker

unread,
Jan 19, 2018, 6:39:39 PM1/19/18
to project...@googlegroups.com
Yes, you can either put the @Accessors(chain=true) on the type, or put lombok.accessors.chain=true in lombok.config. 

The reason it is not the default behavior is the that's not a valid java been according to the beanspec.
Reply all
Reply to author
Forward
0 new messages