Path: blob/master/src/java.base/share/classes/java/nio/file/StandardWatchEventKinds.java
41159 views
/*1* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio.file;2627/**28* Defines the <em>standard</em> event kinds.29*30* @since 1.731*/3233public final class StandardWatchEventKinds {34private StandardWatchEventKinds() { }3536/**37* A special event to indicate that events may have been lost or38* discarded.39*40* <p> The {@link WatchEvent#context context} for this event is41* implementation specific and may be {@code null}. The event {@link42* WatchEvent#count count} may be greater than {@code 1}.43*44* @see WatchService45*/46public static final WatchEvent.Kind<Object> OVERFLOW =47new StdWatchEventKind<Object>("OVERFLOW", Object.class);4849/**50* Directory entry created.51*52* <p> When a directory is registered for this event then the {@link WatchKey}53* is queued when it is observed that an entry is created in the directory54* or renamed into the directory. The event {@link WatchEvent#count count}55* for this event is always {@code 1}.56*/57public static final WatchEvent.Kind<Path> ENTRY_CREATE =58new StdWatchEventKind<Path>("ENTRY_CREATE", Path.class);5960/**61* Directory entry deleted.62*63* <p> When a directory is registered for this event then the {@link WatchKey}64* is queued when it is observed that an entry is deleted or renamed out of65* the directory. The event {@link WatchEvent#count count} for this event66* is always {@code 1}.67*/68public static final WatchEvent.Kind<Path> ENTRY_DELETE =69new StdWatchEventKind<Path>("ENTRY_DELETE", Path.class);7071/**72* Directory entry modified.73*74* <p> When a directory is registered for this event then the {@link WatchKey}75* is queued when it is observed that an entry in the directory has been76* modified. The event {@link WatchEvent#count count} for this event is77* {@code 1} or greater.78*/79public static final WatchEvent.Kind<Path> ENTRY_MODIFY =80new StdWatchEventKind<Path>("ENTRY_MODIFY", Path.class);8182private static class StdWatchEventKind<T> implements WatchEvent.Kind<T> {83private final String name;84private final Class<T> type;85StdWatchEventKind(String name, Class<T> type) {86this.name = name;87this.type = type;88}89@Override public String name() { return name; }90@Override public Class<T> type() { return type; }91@Override public String toString() { return name; }92}93}949596