Class ConfigResolverImpl

java.lang.Object
com.mrivanplays.annotationconfig.core.internal.ConfigResolverImpl
All Implemented Interfaces:
ConfigResolver

public final class ConfigResolverImpl extends Object implements ConfigResolver
  • Constructor Details

  • Method Details

    • settings

      public Settings settings()
      Description copied from interface: ConfigResolver
      Returns the Settings instance held by this config resolver.
      Specified by:
      settings in interface ConfigResolver
      Returns:
      settings
      See Also:
    • dump

      public void dump(Object annotatedConfig, File file)
      Description copied from interface: ConfigResolver
      Dumps the specified annotatedConfig to the specified File file. If, at the time of calling this method, the file exists, it will get deleted ( default implementation ).

      If you are going to call ConfigResolver.load(Object, File, Settings) after calling this method, consider using ConfigResolver.loadOrDump(Object, File, Settings) rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.

      Specified by:
      dump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to dump
      file - the file you want to dump the annotated config to
    • dump

      public void dump(Object annotatedConfig, Path path)
      Description copied from interface: ConfigResolver
      Dumps the specified annotatedConfig to the specified Path path. If, at the time of calling this method, the file exists, it will get deleted ( default implementation ).

      If you are going to call ConfigResolver.load(Object, Path, Settings) after calling this method, consider using ConfigResolver.loadOrDump(Object, Path, Settings) rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.

      Specified by:
      dump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to dump
      path - the file path you want to dump the annotation config to
    • dump

      public void dump(Object annotatedConfig, Writer writer)
      Description copied from interface: ConfigResolver
      Dumps the specified annotatedConfig to the specified Writer writer.
      Specified by:
      dump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to dump
      writer - the writer to dump the annotated config to
    • load

      public void load(Object annotatedConfig, File file)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified File file using the default Settings from the builder of this config resolver, or ACDefaultSettings.getDefault().

      If you have called ConfigResolver.dump(Object, File) before calling this method, consider using ConfigResolver.loadOrDump(Object, File) rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.

      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      file - the file you want to load
    • load

      public void load(Object annotatedConfig, Path path)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Path path using the default Settings from the builder of this config resolver, or ACDefaultSettings.getDefault().

      If you have called ConfigResolver.dump(Object, Path) before calling this method, consider using ConfigResolver.loadOrDump(Object, Path) rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.

      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      path - the file path you want to load
    • load

      public void load(Object annotatedConfig, File file, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified File file using the Settings settings specified.

      If you have called ConfigResolver.dump(Object, File) before calling this method, consider using ConfigResolver.loadOrDump(Object, File, Settings) rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.

      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      file - the file you want to load
      settings - the load settings
    • load

      public void load(Object annotatedConfig, Path path, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Path path using the Settings settings specified.

      If you have called ConfigResolver.dump(Object, Path) before calling this method, consider using ConfigResolver.loadOrDump(Object, Path, Settings) rather than calling dump and load one after each other. This way you save CPU time by not making the library find annotations twice.

      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      path - the file path you want to load
      settings - the load settings
    • load

      public void load(Object annotatedConfig, Map<String,Object> values)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Map values using the default Settings from the builder of this config resolver, or ACDefaultSettings.getDefault().
      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      values - the values you want to load
    • load

      public void load(Object annotatedConfig, Map<String,Object> values, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Map values using the Settings settings specified.
      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated you config you want to load to
      values - the values you want to load
      settings - the load settings
    • load

      public void load(Object annotatedConfig, Reader reader)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Reader reader the default Settings from the builder of this config resolver, or ACDefaultSettings.getDefault().

      If you have a File or Path instance before calling that, consider using ConfigResolver.load(Object, File). This way you allow AnnotatedConfig to generate missing options if the load settings allow it.

      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      reader - the reader you want to load
    • load

      public void load(Object annotatedConfig, Reader reader, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Reader reader using the Settings settings specified.

      If you have a File or Path instance before calling that, consider using ConfigResolver.load(Object, File, Settings). This way you allow AnnotatedConfig to generate missing options if the load settings allow it.

      Specified by:
      load in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load to
      reader - the reader you want to load
      settings - the load settings
    • loadOrDump

      public void loadOrDump(Object annotatedConfig, File file)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified File file, if it exists, if not, dumps the specified annotatedConfig to the specified file, using the default Settings from the builder of this config resolver, or ACDefaultSettings.getDefault().
      Specified by:
      loadOrDump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load/dump
      file - the file you want to load/dump to
    • loadOrDump

      public void loadOrDump(Object annotatedConfig, Path path)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Path path, if it exists, if not, dumps the specified annotatedConfig to the specified file, using the default Settings from the builder of this config resolver, or ACDefaultSettings.getDefault().
      Specified by:
      loadOrDump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load/dump
      path - the file path you want to load/dump to
    • loadOrDump

      public void loadOrDump(Object annotatedConfig, File file, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified File file, if it exists, if not, dumps the specified annotatedConfig to the specified file, using the Settings settings specified.
      Specified by:
      loadOrDump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load/dump
      file - the file you want to load/dump to
      settings - the load settings
    • loadOrDump

      public void loadOrDump(Object annotatedConfig, Path path, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the specified annotatedConfig from the specified Path path, if it exists, if not, dumps the specified annotatedConfig to the specified file, using the Settings settings specified.
      Specified by:
      loadOrDump in interface ConfigResolver
      Parameters:
      annotatedConfig - the annotated config you want to load/dump
      path - the file path you want to load/dump to
      settings - the load settings
    • resolveMultiple

      public <T> Map<String,T> resolveMultiple(File dir, Supplier<T> configToResolveTo, WritableObject dumpFile)
      Description copied from interface: ConfigResolver
      Loads the configurations in the File dir specified, and if any do not exist, the defaults (if specified) are dumped to the specified WritableObject dumpFile.
      WARNING: The specified File dir has to be a directory!!!!!
      Specified by:
      resolveMultiple in interface ConfigResolver
      Type Parameters:
      T - configuration type needed
      Parameters:
      dir - the directory to load configurations from
      configToResolveTo - a Supplier of the needed configuration objects
      dumpFile - the default dump file
      Returns:
      a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
    • resolveMultiple

      public <T> Map<String,T> resolveMultiple(File dir, Supplier<T> configToResolveTo, WritableObject dumpFile, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the configurations in the File dir specified, and if any do not exist, the defaults (if specified) are dumped to the specified WritableObject dumpFile.
      WARNING: The specified File dir has to be a directory!!!!!
      Specified by:
      resolveMultiple in interface ConfigResolver
      Type Parameters:
      T - configuration type needed
      Parameters:
      dir - the directory to load configurations from
      configToResolveTo - a Supplier of the needed configuration objects
      dumpFile - the default dump file
      settings - the load settings to use when loading the configurations
      Returns:
      a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
    • resolveMultiple

      public <T> Map<String,T> resolveMultiple(Path dir, Supplier<T> configToResolveTo, WritableObject dumpFile)
      Description copied from interface: ConfigResolver
      Loads the configurations in the Path dir specified, and if any do not exist, the defaults (if specified) are dumped to the specified WritableObject dumpFile.
      WARNING: The specified Path dir has to be a directory!!!!!
      Specified by:
      resolveMultiple in interface ConfigResolver
      Type Parameters:
      T - configuration type needed
      Parameters:
      dir - the directory to load configurations from
      configToResolveTo - a Supplier of the needed configuration objects
      dumpFile - the default dump file
      Returns:
      a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.
    • resolveMultiple

      public <T> Map<String,T> resolveMultiple(Path dir, Supplier<T> configToResolveTo, WritableObject dumpFile, Settings settings)
      Description copied from interface: ConfigResolver
      Loads the configurations in the Path dir specified, and if any do not exist, the defaults (if specified) are dumped to the specified WritableObject dumpFile.
      WARNING: The specified Path dir has to be a directory!!!!!
      Specified by:
      resolveMultiple in interface ConfigResolver
      Type Parameters:
      T - configuration type needed
      Parameters:
      dir - the directory to load configurations from
      configToResolveTo - a Supplier of the needed configuration objects
      dumpFile - the default dump file
      settings - the load settings to use when loading the configurations
      Returns:
      a map of the loaded configurations, key being the file name. If the map is empty then AnnotationConfig couldn't find any configurations in the folder, and you should fall back to the defaults.