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

Convert match methods to sealed interfaces #41

Closed
io7m opened this issue Jan 1, 2022 · 1 comment
Closed

Convert match methods to sealed interfaces #41

io7m opened this issue Jan 1, 2022 · 1 comment

Comments

@io7m
Copy link
Member

io7m commented Jan 1, 2022

The component interface contains a method line this:

  /**
   * Match on the type of component.
   *
   * @param context   A context value passed through to the given functions
   * @param on_button A function evaluated if this component is a button
   * @param on_panel  A function evaluated if this component is a panel
   * @param on_label  A function evaluated if this component is a label
   * @param on_image  A function evaluated if this component is an image
   * @param on_meter  A function evaluated if this component is a meter
   * @param <A>       The type of opaque context values
   * @param <B>       The type of returned values
   *
   * @return The value returned by whichever one of the given functions is evaluated
   */

  <A, B> B matchComponent(
    A context,
    BiFunction<A, SyButtonType, B> on_button,
    BiFunction<A, SyPanelType, B> on_panel,
    BiFunction<A, SyLabelType, B> on_label,
    BiFunction<A, SyImageType, B> on_image,
    BiFunction<A, SyMeterType, B> on_meter);

This is obviously a generic visitor, and now the component type should be a sealed interface instead.

@io7m
Copy link
Member Author

io7m commented Nov 21, 2023

Done.

@io7m io7m closed this as completed Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant