@Test public void testRegister() throws IOException { Watchable watchable = new StubWatchable(); AbstractWatchService.Key key = watcher.register(watchable, ImmutableSet.of(ENTRY_CREATE)); assertThat(key.isValid()).isTrue(); assertThat(key.pollEvents()).isEmpty(); assertThat(key.subscribesTo(ENTRY_CREATE)).isTrue(); assertThat(key.subscribesTo(ENTRY_DELETE)).isFalse(); assertThat(key.watchable()).isEqualTo(watchable); assertThat(key.state()).isEqualTo(READY); }
public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); }
AbstractWatchService implements WatchService { public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); } }
AbstractWatchService implements WatchService { public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); }  }
AbstractWatchService implements WatchService { public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); }  Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes); @VisibleForTesting boolean isOpen(); void cancelled(Key key); @NullableDecl @Override WatchKey poll(); @NullableDecl @Override WatchKey poll(long timeout, TimeUnit unit); @Override WatchKey take(); @Override void close(); }
AbstractWatchService implements WatchService { public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); }  Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes); @VisibleForTesting boolean isOpen(); void cancelled(Key key); @NullableDecl @Override WatchKey poll(); @NullableDecl @Override WatchKey poll(long timeout, TimeUnit unit); @Override WatchKey take(); @Override void close();  }