Class ReloadNotifierImpl<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    ConfijReloadNotifier<T>

    public class ReloadNotifierImpl<T>
    extends java.lang.Object
    implements ConfijReloadNotifier<T>
    Keep track of previous configuration values and compares them to new ones (when the source value / config string changes). Will notify all listeners of the changed value. Given one nested value changes, the parent will also be notified of the change.

    The class is internally thread-safe, but if a config is reloaded before all handlers are registered it will crash out.

    • Constructor Detail

      • ReloadNotifierImpl

        public ReloadNotifierImpl()
    • Method Detail

      • toChildMappings

        protected static java.util.Map<java.net.URI,​BindingResult<?>> toChildMappings​(BindingResult<?> bindingResult)
      • registerReloadHandler

        public <X> void registerReloadHandler​(@NonNull
                                              @NonNull ConfijReloadHandler<X> childReloadHandler,
                                              @NonNull
                                              @NonNull java.lang.Object parent,
                                              java.lang.String childPath,
                                              java.lang.String... childPaths)
        Specified by:
        registerReloadHandler in interface ConfijReloadNotifier<T>
      • registerReloadHandler

        public <X> void registerReloadHandler​(@NonNull
                                              @NonNull ConfijReloadHandler<X> reloadHandler,
                                              @NonNull
                                              X onConfigObject)
        Listen for changes on a config object. Something you got using ConfijBuilder.build().
        Specified by:
        registerReloadHandler in interface ConfijReloadNotifier<T>
        Type Parameters:
        X - the config type
        Parameters:
        reloadHandler - handler to be called when a config object or one of it's children (nested objects) changes
        onConfigObject - the config object on which to listen for changes. no primitives nor cached/reused types.
      • registerReloadHandlerInternal

        protected void registerReloadHandlerInternal​(ConfijReloadHandler<?> reloadHandler,
                                                     java.lang.Object onConfigObject,
                                                     java.lang.String... childPaths)
      • mustFindUniqueConfigObject

        @NonNull
        protected <X> @NonNull java.net.URI mustFindUniqueConfigObject​(X onConfigObject)
      • registerReloadHandlerOnUri

        protected <X> void registerReloadHandlerOnUri​(@NonNull
                                                      @NonNull java.net.URI nodeURI,
                                                      @NonNull
                                                      @NonNull ConfijReloadHandler<X> reloadHandler)
      • findSameValue

        protected <X> void findSameValue​(BindingResult<?> current,
                                         @NonNull
                                         X onConfigObject,
                                         java.util.Set<BindingResult<X>> results)