spring-cloud-open-service-broker
spring-cloud-open-service-broker copied to clipboard
Support for Value Objects for mapping create parameters
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.
Thanks for the suggestion! Seems like a nice complement to the existing API. It probably makes most sense in a 3.x version.