Package dev.prozilla.pine.common.system
Class DirectoryWatcher
java.lang.Object
dev.prozilla.pine.common.event.EventDispatcher<DirectoryWatcher.EventType,String,Event<DirectoryWatcher.EventType,String>>
dev.prozilla.pine.common.system.DirectoryWatcher
- All Implemented Interfaces:
EventDispatcherContext<DirectoryWatcher.EventType,,String, Event<DirectoryWatcher.EventType, String>> Destructible
public class DirectoryWatcher
extends EventDispatcher<DirectoryWatcher.EventType,String,Event<DirectoryWatcher.EventType,String>>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface dev.prozilla.pine.common.event.EventDispatcherContext
EventDispatcherContext.EphemeralEventListener<EventType extends Enum<EventType>,E extends Event<EventType, ?>> -
Field Summary
Fields inherited from class dev.prozilla.pine.common.event.EventDispatcher
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Event<DirectoryWatcher.EventType, String> createEvent(DirectoryWatcher.EventType eventType, String target) Creates an event of a given type with a given target.voiddestroy()Stops the watch thread and closes the watch service.onFileChange(String path, EventListener<Event<DirectoryWatcher.EventType, String>> listener) Adds a listener that listens to changes to a given file.Methods inherited from class dev.prozilla.pine.common.event.EventDispatcher
addListener, dispatchEvent, getLogger, invoke, invoke, off, on, once, propagate, removeListener, setLogger, shouldInvoke, shouldPropagateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.prozilla.pine.common.event.EventDispatcherContext
addListener, addTargetedListener
-
Constructor Details
-
DirectoryWatcher
-
-
Method Details
-
createEvent
@Contract("_, _ -> new") protected Event<DirectoryWatcher.EventType,String> createEvent(DirectoryWatcher.EventType eventType, String target) Description copied from class:EventDispatcherCreates an event of a given type with a given target.- Specified by:
createEventin classEventDispatcher<DirectoryWatcher.EventType,String, Event<DirectoryWatcher.EventType, String>> - Parameters:
eventType- The type of event to createtarget- The target of the event- Returns:
- The new event
-
onFileChange
public EventListener<Event<DirectoryWatcher.EventType,String>> onFileChange(String path, EventListener<Event<DirectoryWatcher.EventType, String>> listener) Adds a listener that listens to changes to a given file.- Parameters:
path- Path to the filelistener- File change listener
-
destroy
public void destroy()Stops the watch thread and closes the watch service.- Specified by:
destroyin interfaceDestructible- Overrides:
destroyin classEventDispatcher<DirectoryWatcher.EventType,String, Event<DirectoryWatcher.EventType, String>>
-