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?
Context
The current API (
ServiceBindingandTypedMapView) allows only for getting direct (i.e. non-nested) properties.To get a nested property, currently something like the following is needed:
This style of accessing nested properties imposes following problems:
Request
Consider introducing a new API that allows searching for specific properties.
Suggestions
An API for the
TypedMapViewcould look like this:One could also consider adding extra API for primitive return types:
Questions
ServiceBindingvs.TypedMapView)