class SW360ComponentClientAdapterAsyncImpl implements SW360ComponentClientAdapterAsync {

    @Override
    public CompletableFuture<Optional<SW360Component>> getComponentByName(String componentName) {
        ComponentSearchParams searchParams = ComponentSearchParams.builder()
                .withName(componentName)
                .build();
        return getComponentClient().search(searchParams)
                .thenCompose(components ->
                        components.getResult().stream()
                                .filter(c -> c.getName().equals(componentName))
                                .map(c -> SW360HalResourceUtility.getLastIndexOfSelfLink(c.getLinks()).orElse(""))
                                .map(this::getComponentById)
                                .findFirst()
                                .orElse(CompletableFuture.completedFuture(Optional.empty()))
                );
    }

    public  SW360ComponentClientAdapterAsyncImpl(SW360ComponentClient client);

}