public static Store.Provider selectStoreProvider(
      ServiceProvider<Service> serviceProvider, Set<ResourceType<?>> resourceTypes, Collection<ServiceConfiguration<?>> serviceConfigs) {

    Collection<Store.Provider> storeProviders = serviceProvider.getServicesOfType(Store.Provider.class);
    List<Store.Provider> filteredStoreProviders = storeProviders.stream().filter(provider -> !(provider instanceof WrapperStore.Provider)).collect(Collectors.toList());
    int highRank = 0;
    List<Store.Provider> rankingProviders = new ArrayList<>();
    for (Store.Provider provider : filteredStoreProviders) {
      int rank = provider.rank(resourceTypes, serviceConfigs);
      if (rank > highRank) {
        highRank = rank;
        rankingProviders.clear();
        rankingProviders.add(provider);
      } else if (rank != 0 && rank == highRank) {
        rankingProviders.add(provider);
      }
    }

    if (rankingProviders.isEmpty()) {
      StringBuilder sb = new StringBuilder("No Store.Provider found to handle configured resource types ");
      sb.append(resourceTypes);
      sb.append(" from ");
      formatStoreProviders(filteredStoreProviders, sb);
      throw new IllegalStateException(sb.toString());
    } else if (rankingProviders.size() > 1) {
      StringBuilder sb = new StringBuilder("Multiple Store.Providers found to handle configured resource types ");
      sb.append(resourceTypes);
      sb.append(": ");
      formatStoreProviders(rankingProviders, sb);
      throw new IllegalStateException(sb.toString());
    }

    return rankingProviders.get(0);
  }
public static Store . Provider selectStoreProvider ( ServiceProvider < Service > serviceProvider , Set < ResourceType < ? > > resourceTypes , Collection < ServiceConfiguration < ? > > serviceConfigs ) { Collection < Store . Provider > storeProviders = serviceProvider . getServicesOfType ( Store . Provider . class ) ; List < Store . Provider > filteredStoreProviders = storeProviders . stream ( ) . filter ( provider -> ! ( provider instanceof WrapperStore . Provider ) ) . collect ( Collectors . toList ( ) ) ; int highRank = 0 ; List < Store . Provider > rankingProviders = new ArrayList < > ( ) ; for ( Store . Provider provider : filteredStoreProviders ) { int rank = provider . rank ( resourceTypes , serviceConfigs ) ; if ( rank > highRank ) { highRank = rank ; rankingProviders . clear ( ) ; rankingProviders . add ( provider ) ; } else if ( rank != 0 && rank == highRank ) { rankingProviders . add ( provider ) ; } } if ( rankingProviders . isEmpty ( ) ) { StringBuilder sb = new StringBuilder ( "No Store.Provider found to handle configured resource types " ) ; sb . append ( resourceTypes ) ; sb . append ( " from " ) ; formatStoreProviders ( filteredStoreProviders , sb ) ; throw new IllegalStateException ( sb . toString ( ) ) ; } else if ( rankingProviders . size ( ) > 1 ) { StringBuilder sb = new StringBuilder ( "Multiple Store.Providers found to handle configured resource types " ) ; sb . append ( resourceTypes ) ; sb . append ( ": " ) ; formatStoreProviders ( rankingProviders , sb ) ; throw new IllegalStateException ( sb . toString ( ) ) ; } return rankingProviders . get ( 0 ) ; }
Chooses a {@link org.ehcache.core.spi.store.Store.Provider Store.Provider} from those
available through the {@link ServiceLocator} that best supports the resource types and
service configurations provided.  This method relies on the
{@link Store.Provider#rank(Set, Collection) Store.Provider.rank} method in making the
selection.

@param serviceProvider the {@code ServiceProvider} instance to use
@param resourceTypes the set of {@code ResourceType}s that must be supported by the provider
@param serviceConfigs the collection of {@code ServiceConfiguration}s used to influence the
selection

@return the non-{@code null} {@code Store.Provider} implementation chosen

@throws IllegalStateException if no suitable {@code Store.Provider} is available or if
multiple {@code Store.Provider} implementations return the same top ranking