class StorageStrategyUtils {

    public static boolean checkReferentOfferUsageInStrategiesValid(List<StorageStrategy> storageStrategies) {
        // check if a referent offer is not used in more than one strategies
        Map<String, String> referentOfferByStrategy = storageStrategies.stream()
                .filter(strategy -> strategy.getOffers().stream()
                            .filter(OfferReference::isReferent)
                            .filter(OfferReference::isEnabled)
                            .map(OfferReference::getId)
                            .count() == 1)
                .collect(Collectors.toMap(
                        StorageStrategy::getId,
                        strategy -> strategy.getOffers().stream()
                            .filter(OfferReference::isReferent)
                            .filter(OfferReference::isEnabled)
                            .map(OfferReference::getId).findFirst().get()));
        return referentOfferByStrategy.keySet().size() == new HashSet<>(referentOfferByStrategy.values()).size();
    }

}