Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Value Objects for mapping create parameters #332

Open
rdgoite opened this issue Sep 21, 2021 · 1 comment
Open

Support for Value Objects for mapping create parameters #332

rdgoite opened this issue Sep 21, 2021 · 1 comment

Comments

@rdgoite
Copy link

rdgoite commented Sep 21, 2021

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 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
@royclarkson
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants