Interface Gestalt

  • All Known Implementing Classes:
    GestaltCache, GestaltCore

    public interface Gestalt
    Central access point to Gestalt that has API's to build and get configurations.
    • Method Summary

      All Methods Instance Methods Abstract 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.
      void loadConfigs()
      Loads the configurations from the source and builds a config tree.
      void registerListener​(CoreReloadListener listener)
      register a core event listener.
      void removeListener​(CoreReloadListener listener)
      remove a core event listener.
    • Method Detail

      • loadConfigs

        void loadConfigs()
                  throws GestaltException
        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.
        Throws:
        GestaltException - any errors
      • getConfig

        <T> T getConfig​(java.lang.String path,
                        java.lang.Class<T> klass)
                 throws GestaltException
        Get a config for a path and a given class.
        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

        <T> T getConfig​(java.lang.String path,
                        java.lang.Class<T> klass,
                        Tags tags)
                 throws GestaltException
        Get a config for a path and a given class.
        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

        <T> T getConfig​(java.lang.String path,
                        TypeCapture<T> klass)
                 throws GestaltException
        Get a config for a path and a given TypeCapture.
        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

        <T> T getConfig​(java.lang.String path,
                        TypeCapture<T> klass,
                        Tags tags)
                 throws GestaltException
        Get a config for a path and a given TypeCapture.
        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

        <T> T getConfig​(java.lang.String path,
                        T defaultVal,
                        java.lang.Class<T> klass)
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        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

        <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. If the config is missing or invalid it will return the default value.
        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

        <T> T getConfig​(java.lang.String path,
                        T defaultVal,
                        TypeCapture<T> klass)
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        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

        <T> T getConfig​(java.lang.String path,
                        T defaultVal,
                        TypeCapture<T> klass,
                        Tags tags)
        Get a config for a path and a given class. If the config is missing or invalid it will return the default value.
        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

        <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. If there are any exceptions or errors it will return an Optional.empty()
        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

        <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. If there are any exceptions or errors it will return an Optional.empty()
        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

        <T> java.util.Optional<T> getConfigOptional​(java.lang.String path,
                                                    TypeCapture<T> klass)
        Get a config Optional for a path and a given TypeCapture. If there are any exceptions or errors it will return an Optional.empty()
        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

        <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. If there are any exceptions or errors it will return an Optional.empty()
        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.
      • registerListener

        void registerListener​(CoreReloadListener listener)
        register a core event listener.
        Parameters:
        listener - to register
      • removeListener

        void removeListener​(CoreReloadListener listener)
        remove a core event listener.
        Parameters:
        listener - to remove