Besides the traditional Java Beans getters and setters, it makes code more concise and readable if fluent interface methods methods are provided to mutate members. As an example consider the MonitoredElement class with the following fluent interface methods:
such fluent interface methods should be provided for (domain) objects that require a lot of mutators to be invoked (and with fluent interfaces we can nicely chain those invocations and even bring structure to the mutator invocations by using appropriate indention). E.g.:
MonitoredElement topology = new MonitoredElement().withId("ServiceTopology").withLevel(MonitoredElement.MonitoredElementLevel.SERVICE_TOPOLOGY);
Besides the traditional Java Beans getters and setters, it makes code more concise and readable if fluent interface methods methods are provided to mutate members. As an example consider the
MonitoredElement
class with the following fluent interface methods:such fluent interface methods should be provided for (domain) objects that require a lot of mutators to be invoked (and with fluent interfaces we can nicely chain those invocations and even bring structure to the mutator invocations by using appropriate indention). E.g.: