Package com.google.common.jimfs
Class AbstractWatchService.Key
- java.lang.Object
-
- com.google.common.jimfs.AbstractWatchService.Key
-
- All Implemented Interfaces:
java.nio.file.WatchKey
- Enclosing class:
- AbstractWatchService
static final class AbstractWatchService.Key extends java.lang.Object implements java.nio.file.WatchKey
Implementation ofWatchKey
for anAbstractWatchService
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AbstractWatchService.Key.State
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.BlockingQueue<java.nio.file.WatchEvent<?>>
events
(package private) static int
MAX_QUEUE_SIZE
private java.util.concurrent.atomic.AtomicInteger
overflow
private java.util.concurrent.atomic.AtomicReference<AbstractWatchService.Key.State>
state
private com.google.common.collect.ImmutableSet<java.nio.file.WatchEvent.Kind<?>>
subscribedTypes
private java.util.concurrent.atomic.AtomicBoolean
valid
private java.nio.file.Watchable
watchable
private AbstractWatchService
watcher
-
Constructor Summary
Constructors Constructor Description Key(AbstractWatchService watcher, @Nullable java.nio.file.Watchable watchable, java.lang.Iterable<? extends java.nio.file.WatchEvent.Kind<?>> subscribedTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
boolean
isValid()
private static java.nio.file.WatchEvent<java.lang.Object>
overflowEvent(int count)
java.util.List<java.nio.file.WatchEvent<?>>
pollEvents()
void
post(java.nio.file.WatchEvent<?> event)
Posts the given event to this key.boolean
reset()
void
signal()
Sets the state to SIGNALLED and enqueues this key with the watcher if it was previously in the READY state.(package private) AbstractWatchService.Key.State
state()
Gets the current state of this key, State.READY or SIGNALLED.boolean
subscribesTo(java.nio.file.WatchEvent.Kind<?> eventType)
Gets whether or not this key is subscribed to the given type of event.java.nio.file.Watchable
watchable()
-
-
-
Field Detail
-
MAX_QUEUE_SIZE
static final int MAX_QUEUE_SIZE
- See Also:
- Constant Field Values
-
watcher
private final AbstractWatchService watcher
-
watchable
private final java.nio.file.Watchable watchable
-
subscribedTypes
private final com.google.common.collect.ImmutableSet<java.nio.file.WatchEvent.Kind<?>> subscribedTypes
-
state
private final java.util.concurrent.atomic.AtomicReference<AbstractWatchService.Key.State> state
-
valid
private final java.util.concurrent.atomic.AtomicBoolean valid
-
overflow
private final java.util.concurrent.atomic.AtomicInteger overflow
-
events
private final java.util.concurrent.BlockingQueue<java.nio.file.WatchEvent<?>> events
-
-
Constructor Detail
-
Key
public Key(AbstractWatchService watcher, @Nullable java.nio.file.Watchable watchable, java.lang.Iterable<? extends java.nio.file.WatchEvent.Kind<?>> subscribedTypes)
-
-
Method Detail
-
overflowEvent
private static java.nio.file.WatchEvent<java.lang.Object> overflowEvent(int count)
-
state
AbstractWatchService.Key.State state()
Gets the current state of this key, State.READY or SIGNALLED.
-
subscribesTo
public boolean subscribesTo(java.nio.file.WatchEvent.Kind<?> eventType)
Gets whether or not this key is subscribed to the given type of event.
-
post
public void post(java.nio.file.WatchEvent<?> event)
Posts the given event to this key. After posting one or more events,signal()
must be called to cause the key to be enqueued with the watch service.
-
signal
public void signal()
Sets the state to SIGNALLED and enqueues this key with the watcher if it was previously in the READY state.
-
isValid
public boolean isValid()
- Specified by:
isValid
in interfacejava.nio.file.WatchKey
-
pollEvents
public java.util.List<java.nio.file.WatchEvent<?>> pollEvents()
- Specified by:
pollEvents
in interfacejava.nio.file.WatchKey
-
reset
@CanIgnoreReturnValue public boolean reset()
- Specified by:
reset
in interfacejava.nio.file.WatchKey
-
cancel
public void cancel()
- Specified by:
cancel
in interfacejava.nio.file.WatchKey
-
watchable
public java.nio.file.Watchable watchable()
- Specified by:
watchable
in interfacejava.nio.file.WatchKey
-
-