You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the time of writing, the CreateServiceInstanceRequest provides a getParameters method that takes a class to convert the parameters to. This class needs to be a Java bean class for this work; if there's no setter for the field, it's not set. However, I think it will be useful in many cases to be able to use immutable objects as well. In Domain Driven Design, Value Objects are meant to be immutable, and create parameters seem to fit the pattern.
For example, if I have the following Parameters class (annotated with Lombok for brevity):
@Value
@With
public class Parameters {
private String name;
private Integer count;
}
I want to be able to do:
public Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request) {
var params = request.getParameters(Parameters.class);
var transformed = params.withName("transform" + params.getName());
}
There are many reasons people would want to work with Value Objects instead of Java beans.
The text was updated successfully, but these errors were encountered:
rdgoite
changed the title
Support for (almost) immutable Java objects for mapping create parameters
Support for Value Objects for mapping create parameters
Sep 21, 2021
At the time of writing, the
CreateServiceInstanceRequest
provides agetParameters
method that takes a class to convert the parameters to. This class needs to be a Java bean class for this work; if there's no setter for the field, it's not set. However, I think it will be useful in many cases to be able to use immutable objects as well. In Domain Driven Design, Value Objects are meant to be immutable, and create parameters seem to fit the pattern.For example, if I have the following
Parameters
class (annotated with Lombok for brevity):I want to be able to do:
There are many reasons people would want to work with Value Objects instead of Java beans.
The text was updated successfully, but these errors were encountered: