Class 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 of WatchKey for an AbstractWatchService.
    • 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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • watchable

        private final java.nio.file.Watchable watchable
      • subscribedTypes

        private final com.google.common.collect.ImmutableSet<java.nio.file.WatchEvent.Kind<?>> subscribedTypes
      • 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)
      • 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 interface java.nio.file.WatchKey
      • pollEvents

        public java.util.List<java.nio.file.WatchEvent<?>> pollEvents()
        Specified by:
        pollEvents in interface java.nio.file.WatchKey
      • reset

        @CanIgnoreReturnValue
        public boolean reset()
        Specified by:
        reset in interface java.nio.file.WatchKey
      • cancel

        public void cancel()
        Specified by:
        cancel in interface java.nio.file.WatchKey
      • watchable

        public java.nio.file.Watchable watchable()
        Specified by:
        watchable in interface java.nio.file.WatchKey