content: package net.afyer.afybroker.server.config;
  
  import java.io.*;
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * @author Nipuru
   * @since 2022/7/31 12:09
   */
  public abstract class ConfigurationProvider {
  
      private static final Map<Class<? extends ConfigurationProvider>, ConfigurationProvider> providers = new HashMap<>();
  
      static {
          try {
              providers.put(YamlConfiguration.class, new YamlConfiguration());
          } catch (NoClassDefFoundError ignored) {
          }
  
          try {
              providers.put(JsonConfiguration.class, new JsonConfiguration());
          } catch (NoClassDefFoundError ignored) {
          }
      }
  
      public static ConfigurationProvider getProvider(Class<? extends ConfigurationProvider> provider) {
          return providers.get(provider);
      }
  
      public abstract void save(Configuration config, File file) throws IOException;
  
      public abstract void save(Configuration config, Writer writer);
  
      public abstract Configuration load(File file) throws IOException;
  
      public abstract Configuration load(File file, Configuration defaults) throws IOException;
  
      public abstract Configuration load(Reader reader);
  
      public abstract Configuration load(Reader reader, Configuration defaults);
  
      public abstract Configuration load(InputStream is);
  
      public abstract Configuration load(InputStream is, Configuration defaults);
  
      public abstract Configuration load(String string);
  
      public abstract Configuration load(String string, Configuration defaults);
  }
  