Class MutabilitySupport

    • Method Detail

      • poll

        public static Runnable poll​(Path path,
                                    Duration duration,
                                    Consumer<Path> updater,
                                    Consumer<Path> cleaner)
        Start polling for changes.
        Parameters:
        path - path to watch
        duration - duration of polling
        updater - consumer that reads the file content and updates properties (in case file is changed)
        cleaner - runnable to clean the properties (in case file is deleted)
        Returns:
        runnable to stop the file watcher
      • watch

        public static Runnable watch​(Path path,
                                     Consumer<Path> updater,
                                     Consumer<Path> cleaner)
        Start watching a file for changes.
        Parameters:
        path - path to watch
        updater - consumer that reads the file content and updates properties
        cleaner - runnable to clean the properties (in case file is deleted)
        Returns:
        runnable to stop the file watcher