class BBInputSetupUtils {

    public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName)
            throws MultipleObjectsFoundException {
        AAIPluralResourceUri uri =
                AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
                        .relatedTo(Types.L3_NETWORKS.getFragment()).queryParam("network-name", networkName);
        Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri);
        L3Network network = null;
        if (!networks.isPresent()) {
            logger.debug("No Networks matched by name");
            return Optional.empty();
        } else {
            if (networks.get().getL3Network().size() > 1) {
                String message =
                        String.format("Multiple networks found for service-instance-id: %s and network-name: %s.",
                                serviceInstanceId, networkName);
                throw new MultipleObjectsFoundException(message);
            } else {
                network = networks.get().getL3Network().get(0);
            }
            return Optional.of(network);
        }
    }

}