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

Feat: Introduce API for Searching (nested) Service Binding Properties #42

Open
Johannes-Schneider opened this issue Aug 11, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Johannes-Schneider
Copy link
Contributor

Context

The current API (ServiceBinding and TypedMapView) allows only for getting direct (i.e. non-nested) properties.
To get a nested property, currently something like the following is needed:

final ServiceBinding serviceBinding;
final TypedMapView mapView = TypedMapView.of(serviceBinding);

final String
    propertyValue =
    mapView.getMapView("key1").getMapView("key2").getListView("key3").getMapView(2).getString("key4");

This style of accessing nested properties imposes following problems:

  • The exact structure of the Service Binding must be know
  • The access is very verbose and not very well readable

Request

Consider introducing a new API that allows searching for specific properties.

Suggestions

An API for the TypedMapView could look like this:

public <T> Collection<T> find(@Nonnull final Class<? extends T> entryType, @Nonnull final String entryKeyPattern );
public <T> Optional<T> findFirst( @Nonnull final Class<? extends T> entryType, @Nonnull final String entryKeyPattern );

One could also consider adding extra API for primitive return types:

public int findInteger( @Nonnull final String entryKeyPattern ) throws KeyNotFoundException;

Questions

  • Where should we introduce such a new API (ServiceBinding vs. TypedMapView)
  • Do we want to support some sort path matching?
@Johannes-Schneider Johannes-Schneider added the enhancement New feature or request label Aug 11, 2022
@Johannes-Schneider Johannes-Schneider changed the title Feat: Introduce API for Searching for (nested) Service Binding Properties Feat: Introduce API for Searching (nested) Service Binding Properties Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant