class SimpleFlowMapper implements FlowMapper {

    @Override
    public Optional<FlowUri> getFlowMapping(final String agentClass) throws FlowMapperException {
        if (StringUtils.isBlank(agentClass)) {
            throw new IllegalArgumentException("Agent class cannot be null or blank");
        }

        try {
            final String registryUrl = clientFactory.getNiFiRegistryUrl();
            final Optional<String> bucketIdOptional = clientFactory.resolveNiFiRegistryBucketId();

            if (bucketIdOptional.isPresent()) {
                final String bucketId = bucketIdOptional.get();
                final NiFiRegistryClient client = clientFactory.getClient();
                final FlowClient flowClient = client.getFlowClient();
                final List<VersionedFlow> flows = flowClient.getByBucket(bucketId);

                final Optional<String> flowId = flows.stream()
                        .filter(f -> f.getName().equals(agentClass))
                        .map(f -> f.getIdentifier())
                        .findFirst();

                if (flowId.isPresent()) {
                    final FlowUri flowUri = new FlowUri(registryUrl, bucketId, flowId.get());
                    return Optional.of(flowUri);
                }
            }
            return Optional.empty();

        } catch (final Exception e) {
            throw new FlowMapperException("Unable to get flow mapping for " + agentClass + " due to " + e.getMessage(), e);
        }
    }

    @Autowired public  SimpleFlowMapper(final C2NiFiRegistryClient clientFactory);

}