spring-cloud-open-service-broker icon indicating copy to clipboard operation
spring-cloud-open-service-broker copied to clipboard

Support for Value Objects for mapping create parameters

Open rdgoite opened this issue 3 years ago • 1 comments

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.

rdgoite avatar Sep 21 '21 14:09 rdgoite

Thanks for the suggestion! Seems like a nice complement to the existing API. It probably makes most sense in a 3.x version.

royclarkson avatar Jan 12 '22 21:01 royclarkson