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

Builder and getter APIs for components #101

Open
Tomboyo opened this issue Oct 19, 2023 · 0 comments
Open

Builder and getter APIs for components #101

Tomboyo opened this issue Oct 19, 2023 · 0 comments

Comments

@Tomboyo
Copy link
Owner

Tomboyo commented Oct 19, 2023

For all mandatory components,

  • The builder API must have a compose$Type($Type) setter
  • The getter API must have a $Type as$Type() getter
MyComponent foo = MyModel.newBuilder()
    .composeMyComponenet(instance)
    .buildUnvalidated()
    .asMyComponent();

For all non-mandatory componenets,

  • The getter API must instead be optionally typed, as Optional<$Type> as$Type()
  • Optionals must be empty if any mandatory property of a component is null on the composed model
  • Optionals must be nonempty if every mandatory property of a component is non-null
  • Non-mandatory properties have no impact on whether Optionals are empty
Optional<MyComponent> foo = MyModel.newBuilder()
    .composeMyComponenet(instance)
    .buildUnvalidated()
    .asMyComponent();
@Tomboyo Tomboyo added this to the Compositional Types milestone Oct 19, 2023
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

1 participant