Skip to content

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

Description

@Johannes-Schneider

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions