src/share/classes/javax/lang/model/element/ElementKind.java

changeset 1
9a66ca7c79fa
child 554
9d9f26857129
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/javax/lang/model/element/ElementKind.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,123 @@
     1.4 +/*
     1.5 + * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +package javax.lang.model.element;
    1.30 +
    1.31 +/**
    1.32 + * The {@code kind} of an element.
    1.33 + *
    1.34 + * <p>Note that it is possible additional element kinds will be added
    1.35 + * to accommodate new, currently unknown, language structures added to
    1.36 + * future versions of the Java&trade; programming language.
    1.37 + *
    1.38 + * @author Joseph D. Darcy
    1.39 + * @author Scott Seligman
    1.40 + * @author Peter von der Ah&eacute;
    1.41 + * @see Element
    1.42 + * @since 1.6
    1.43 + */
    1.44 +public enum ElementKind {
    1.45 +
    1.46 +    /** A package. */
    1.47 +    PACKAGE,
    1.48 +
    1.49 +    // Declared types
    1.50 +    /** An enum type. */
    1.51 +    ENUM,
    1.52 +    /** A class not described by a more specific kind (like {@code ENUM}). */
    1.53 +    CLASS,
    1.54 +    /** An annotation type. */
    1.55 +    ANNOTATION_TYPE,
    1.56 +    /**
    1.57 +     * An interface not described by a more specific kind (like
    1.58 +     * {@code ANNOTATION_TYPE}).
    1.59 +     */
    1.60 +    INTERFACE,
    1.61 +
    1.62 +    // Variables
    1.63 +    /** An enum constant. */
    1.64 +    ENUM_CONSTANT,
    1.65 +    /**
    1.66 +     * A field not described by a more specific kind (like
    1.67 +     * {@code ENUM_CONSTANT}).
    1.68 +     */
    1.69 +    FIELD,
    1.70 +    /** A parameter of a method or constructor. */
    1.71 +    PARAMETER,
    1.72 +    /** A local variable. */
    1.73 +    LOCAL_VARIABLE,
    1.74 +    /** A parameter of an exception handler. */
    1.75 +    EXCEPTION_PARAMETER,
    1.76 +
    1.77 +    // Executables
    1.78 +    /** A method. */
    1.79 +    METHOD,
    1.80 +    /** A constructor. */
    1.81 +    CONSTRUCTOR,
    1.82 +    /** A static initializer. */
    1.83 +    STATIC_INIT,
    1.84 +    /** An instance initializer. */
    1.85 +    INSTANCE_INIT,
    1.86 +
    1.87 +    /** A type parameter. */
    1.88 +    TYPE_PARAMETER,
    1.89 +
    1.90 +    /**
    1.91 +     * An implementation-reserved element.  This is not the element
    1.92 +     * you are looking for.
    1.93 +     */
    1.94 +    OTHER;
    1.95 +
    1.96 +
    1.97 +    /**
    1.98 +     * Returns {@code true} if this is a kind of class:
    1.99 +     * either {@code CLASS} or {@code ENUM}.
   1.100 +     *
   1.101 +     * @return {@code true} if this is a kind of class
   1.102 +     */
   1.103 +    public boolean isClass() {
   1.104 +        return this == CLASS || this == ENUM;
   1.105 +    }
   1.106 +
   1.107 +    /**
   1.108 +     * Returns {@code true} if this is a kind of interface:
   1.109 +     * either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
   1.110 +     *
   1.111 +     * @return {@code true} if this is a kind of interface
   1.112 +     */
   1.113 +    public boolean isInterface() {
   1.114 +        return this == INTERFACE || this == ANNOTATION_TYPE;
   1.115 +    }
   1.116 +
   1.117 +    /**
   1.118 +     * Returns {@code true} if this is a kind of field:
   1.119 +     * either {@code FIELD} or {@code ENUM_CONSTANT}.
   1.120 +     *
   1.121 +     * @return {@code true} if this is a kind of field
   1.122 +     */
   1.123 +    public boolean isField() {
   1.124 +        return this == FIELD || this == ENUM_CONSTANT;
   1.125 +    }
   1.126 +}

mercurial