Class GestaltCore

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T getConfig​(java.lang.String path, java.lang.Class<T> klass)
      Get a config for a path and a given class.
      <T> T getConfig​(java.lang.String path, java.lang.Class<T> klass, Tags tags)
      Get a config for a path and a given class.
      <T> T getConfig​(java.lang.String path, TypeCapture<T> klass)
      Get a config for a path and a given TypeCapture.
      <T> T getConfig​(java.lang.String path, TypeCapture<T> klass, Tags tags)
      Get a config for a path and a given TypeCapture.
      <T> T getConfig​(java.lang.String path, T defaultVal, java.lang.Class<T> klass)
      Get a config for a path and a given class.
      <T> T getConfig​(java.lang.String path, T defaultVal, java.lang.Class<T> klass, Tags tags)
      Get a config for a path and a given class.
      <T> T getConfig​(java.lang.String path, T defaultVal, TypeCapture<T> klass)
      Get a config for a path and a given class.
      <T> T getConfig​(java.lang.String path, T defaultVal, TypeCapture<T> klass, Tags tags)
      Get a config for a path and a given class.
      <T> java.util.Optional<T> getConfigOptional​(java.lang.String path, java.lang.Class<T> klass)
      Get a config Optional for a path and a given class.
      <T> java.util.Optional<T> getConfigOptional​(java.lang.String path, java.lang.Class<T> klass, Tags tags)
      Get a config Optional for a path and a given class.
      <T> java.util.Optional<T> getConfigOptional​(java.lang.String path, TypeCapture<T> klass)
      Get a config Optional for a path and a given TypeCapture.
      <T> java.util.Optional<T> getConfigOptional​(java.lang.String path, TypeCapture<T> klass, Tags tags)
      Get a config Optional for a path and a given TypeCapture.
      DecoderService getDecoderService()  
      void loadConfigs()
      Loads the configurations from the source and builds a config tree.
      void registerListener​(CoreReloadListener listener)
      register a core event listener.
      void reload​(ConfigSource reloadSource)
      Find the specific source that we wish to reload.
      void removeListener​(CoreReloadListener listener)
      remove a core event listener.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GestaltCore

        public GestaltCore​(ConfigLoaderService configLoaderService,
                           java.util.List<ConfigSourcePackage> configSourcePackages,
                           DecoderService decoderService,
                           SentenceLexer sentenceLexer,
                           GestaltConfig gestaltConfig,
                           ConfigNodeService configNodeService,
                           CoreReloadListenersContainer reloadStrategy,
                           java.util.List<PostProcessor> postProcessor,
                           Tags defaultTags)
        Constructor for Gestalt,you can call it manually but the best way to use this is though the GestaltBuilder.
        Parameters:
        configLoaderService - configLoaderService to hold all config loaders
        configSourcePackages - sources we wish to load the configs from. We load the sources in the order they are provided. Overriding older values with new one where needed
        decoderService - decoderService to hold all decoders
        sentenceLexer - sentenceLexer to parse the configuration paths when doing searches.
        gestaltConfig - configuration for the Gestalt
        configNodeService - configNodeService core functionality to manage nodes
        reloadStrategy - reloadStrategy holds all reload listeners
        postProcessor - postProcessor list of post processors
        defaultTags - Default set of tags to apply to all calls to get a configuration where tags are not provided.
    • Method Detail

      • loadConfigs

        public void loadConfigs()
                         throws GestaltException
        Description copied from interface: Gestalt
        Loads the configurations from the source and builds a config tree. For each sources it will find the config loader that matches the source format. It will use the config loader to build a config node tree. Then merge the configs in order. With the newer configs overwriting the older configs.
        Specified by:
        loadConfigs in interface Gestalt
        Throws:
        GestaltException - any errors
      • reload

        public void reload​(ConfigSource reloadSource)
                    throws GestaltException
        Find the specific source that we wish to reload. Then reload the config and update the configNodeService with the new config node tree.
        Specified by:
        reload in interface ConfigReloadListener
        Parameters:
        reloadSource - source to reload
        Throws:
        GestaltException - any exception
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               java.lang.Class<T> klass)
                        throws GestaltException
        Description copied from interface: Gestalt
        Get a config for a path and a given class.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - class to get the class for.
        Returns:
        the configuration.
        Throws:
        GestaltException - any errors such as if there are no configs.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               java.lang.Class<T> klass,
                               Tags tags)
                        throws GestaltException
        Description copied from interface: Gestalt
        Get a config for a path and a given class.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - class to get the class for.
        tags - the tags to match while searching for configs
        Returns:
        the configuration.
        Throws:
        GestaltException - any errors such as if there are no configs.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               TypeCapture<T> klass)
                        throws GestaltException
        Description copied from interface: Gestalt
        Get a config for a path and a given TypeCapture.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - TypeCapture to get the class for.
        Returns:
        the configuration.
        Throws:
        GestaltException - any errors such as if there are no configs.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               TypeCapture<T> klass,
                               Tags tags)
                        throws GestaltException
        Description copied from interface: Gestalt
        Get a config for a path and a given TypeCapture.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - TypeCapture to get the class for.
        tags - the tags to match while searching for configs
        Returns:
        the configuration.
        Throws:
        GestaltException - any errors such as if there are no configs.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               T defaultVal,
                               java.lang.Class<T> klass)
        Description copied from interface: Gestalt
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        defaultVal - the default value to return if the config is invalid.
        klass - class to get the class for.
        Returns:
        the configuration, or the default if the configuration is not found.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               T defaultVal,
                               java.lang.Class<T> klass,
                               Tags tags)
        Description copied from interface: Gestalt
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        defaultVal - the default value to return if the config is invalid.
        klass - class to get the class for.
        tags - the tags to match while searching for configs
        Returns:
        the configuration, or the default if the configuration is not found.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               T defaultVal,
                               TypeCapture<T> klass)
        Description copied from interface: Gestalt
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for.
        defaultVal - the default value to return if the config is invalid.
        klass - TypeCapture to get the class for.
        Returns:
        the configuration, or the default if the configuration is not found.
      • getConfig

        public <T> T getConfig​(java.lang.String path,
                               T defaultVal,
                               TypeCapture<T> klass,
                               Tags tags)
        Description copied from interface: Gestalt
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        Specified by:
        getConfig in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for.
        defaultVal - the default value to return if the config is invalid.
        klass - TypeCapture to get the class for.
        tags - the tags to match while searching for configs
        Returns:
        the configuration, or the default if the configuration is not found.
      • getConfigOptional

        public <T> java.util.Optional<T> getConfigOptional​(java.lang.String path,
                                                           java.lang.Class<T> klass)
        Description copied from interface: Gestalt
        Get a config Optional for a path and a given class. If there are any exceptions or errors it will return an Optional.empty()
        Specified by:
        getConfigOptional in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - class to get the class for.
        Returns:
        the configuration or Optional.empty() if it failed.
      • getConfigOptional

        public <T> java.util.Optional<T> getConfigOptional​(java.lang.String path,
                                                           java.lang.Class<T> klass,
                                                           Tags tags)
        Description copied from interface: Gestalt
        Get a config Optional for a path and a given class. If there are any exceptions or errors it will return an Optional.empty()
        Specified by:
        getConfigOptional in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - class to get the class for.
        tags - the tags to match while searching for configs
        Returns:
        the configuration or Optional.empty() if it failed.
      • getConfigOptional

        public <T> java.util.Optional<T> getConfigOptional​(java.lang.String path,
                                                           TypeCapture<T> klass)
        Description copied from interface: Gestalt
        Get a config Optional for a path and a given TypeCapture. If there are any exceptions or errors it will return an Optional.empty()
        Specified by:
        getConfigOptional in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - TypeCapture to get the class for.
        Returns:
        the configuration or Optional.empty() if it failed.
      • getConfigOptional

        public <T> java.util.Optional<T> getConfigOptional​(java.lang.String path,
                                                           TypeCapture<T> klass,
                                                           Tags tags)
        Description copied from interface: Gestalt
        Get a config Optional for a path and a given TypeCapture. If there are any exceptions or errors it will return an Optional.empty()
        Specified by:
        getConfigOptional in interface Gestalt
        Type Parameters:
        T - type of class to get.
        Parameters:
        path - path to get the config for. The path is not case sensitive.
        klass - TypeCapture to get the class for.
        tags - the tags to match while searching for configs
        Returns:
        the configuration or Optional.empty() if it failed.