package it.andtorg.pdi.sdmx;

import it.bancaditalia.oss.sdmx.client.Provider;
import it.bancaditalia.oss.sdmx.client.SDMXClientFactory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by andrea on 04/05/16.
 */
public class SdmxProviderHandler {
  private List<Provider> providers;

  private Map<String, Provider> nameToProviders;
  public SdmxProviderHandler() {
    this.providers = new ArrayList<>(SDMXClientFactory.getProviders().values());
    nameToProviders = new HashMap<>();
    for (Provider p : providers){
      nameToProviders.put(p.getName(),p);
    }
  }

  public List<Provider> getProviders() {
    return providers;
  }

  public Provider getProviderByName(String name){
    return nameToProviders.get(name);
  }

}

@@ -284,13 +284,12 @@
 lic 
-class
+enum
  Sdm
@@ -309,23 +309,27 @@
 ler %7B%0A  
-private
+INSTANCE;%0A 
  List%3CPr
@@ -351,19 +351,10 @@
 rs;%0A
-%0A
   
-private 
 Map%3C
@@ -388,24 +388,18 @@
 viders;%0A
+%0A
  
- public
  SdmxPro

refactor as enum because this should be a singleton