< prev index next >

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

Print this page




  29  * The {@code kind} of an element.
  30  *
  31  * <p>Note that it is possible additional element kinds will be added
  32  * to accommodate new, currently unknown, language structures added to
  33  * future versions of the Java&trade; programming language.
  34  *
  35  * @author Joseph D. Darcy
  36  * @author Scott Seligman
  37  * @author Peter von der Ah&eacute;
  38  * @see Element
  39  * @since 1.6
  40  */
  41 public enum ElementKind {
  42 
  43     /** A package. */
  44     PACKAGE,
  45 
  46     // Declared types
  47     /** An enum type. */
  48     ENUM,
  49     /** A class not described by a more specific kind (like {@code ENUM}). */



  50     CLASS,

  51     /** An annotation type. */
  52     ANNOTATION_TYPE,
  53     /**
  54      * An interface not described by a more specific kind (like
  55      * {@code ANNOTATION_TYPE}).
  56      */
  57     INTERFACE,
  58 
  59     // Variables
  60     /** An enum constant. */
  61     ENUM_CONSTANT,
  62     /**
  63      * A field not described by a more specific kind (like
  64      * {@code ENUM_CONSTANT}).
  65      */
  66     FIELD,
  67     /** A parameter of a method or constructor. */
  68     PARAMETER,
  69     /** A local variable. */
  70     LOCAL_VARIABLE,


  73 
  74     // Executables
  75     /** A method. */
  76     METHOD,
  77     /** A constructor. */
  78     CONSTRUCTOR,
  79     /** A static initializer. */
  80     STATIC_INIT,
  81     /** An instance initializer. */
  82     INSTANCE_INIT,
  83 
  84     /** A type parameter. */
  85     TYPE_PARAMETER,
  86 
  87     /**
  88      * An implementation-reserved element.  This is not the element
  89      * you are looking for.
  90      */
  91     OTHER,
  92 


  93     /**
  94      * A resource variable.
  95      * @since 1.7
  96      */
  97      RESOURCE_VARIABLE,
  98 
  99     /**
 100      * A module.
 101      * @since 9
 102      * @spec JPMS
 103      */
 104      MODULE;
 105 












 106 
 107     /**
 108      * Returns {@code true} if this is a kind of class:
 109      * either {@code CLASS} or {@code ENUM}.
 110      *
 111      * @return {@code true} if this is a kind of class
 112      */
 113     public boolean isClass() {
 114         return this == CLASS || this == ENUM;
 115     }
 116 
 117     /**
 118      * Returns {@code true} if this is a kind of interface:
 119      * either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
 120      *
 121      * @return {@code true} if this is a kind of interface
 122      */
 123     public boolean isInterface() {
 124         return this == INTERFACE || this == ANNOTATION_TYPE;
 125     }
 126 
 127     /**
 128      * Returns {@code true} if this is a kind of field:
 129      * either {@code FIELD} or {@code ENUM_CONSTANT}.
 130      *
 131      * @return {@code true} if this is a kind of field
 132      */
 133     public boolean isField() {
 134         return this == FIELD || this == ENUM_CONSTANT;


  29  * The {@code kind} of an element.
  30  *
  31  * <p>Note that it is possible additional element kinds will be added
  32  * to accommodate new, currently unknown, language structures added to
  33  * future versions of the Java&trade; programming language.
  34  *
  35  * @author Joseph D. Darcy
  36  * @author Scott Seligman
  37  * @author Peter von der Ah&eacute;
  38  * @see Element
  39  * @since 1.6
  40  */
  41 public enum ElementKind {
  42 
  43     /** A package. */
  44     PACKAGE,
  45 
  46     // Declared types
  47     /** An enum type. */
  48     ENUM,
  49     /**
  50      * A class not described by a more specific kind (like {@code
  51      * ENUM} or {@code RECORD}).
  52      */
  53     CLASS,
  54 
  55     /** An annotation type. */
  56     ANNOTATION_TYPE,
  57     /**
  58      * An interface not described by a more specific kind (like
  59      * {@code ANNOTATION_TYPE}).
  60      */
  61     INTERFACE,
  62 
  63     // Variables
  64     /** An enum constant. */
  65     ENUM_CONSTANT,
  66     /**
  67      * A field not described by a more specific kind (like
  68      * {@code ENUM_CONSTANT}).
  69      */
  70     FIELD,
  71     /** A parameter of a method or constructor. */
  72     PARAMETER,
  73     /** A local variable. */
  74     LOCAL_VARIABLE,


  77 
  78     // Executables
  79     /** A method. */
  80     METHOD,
  81     /** A constructor. */
  82     CONSTRUCTOR,
  83     /** A static initializer. */
  84     STATIC_INIT,
  85     /** An instance initializer. */
  86     INSTANCE_INIT,
  87 
  88     /** A type parameter. */
  89     TYPE_PARAMETER,
  90 
  91     /**
  92      * An implementation-reserved element.  This is not the element
  93      * you are looking for.
  94      */
  95     OTHER,
  96 
  97     // Constants added since initial release
  98 
  99     /**
 100      * A resource variable.
 101      * @since 1.7
 102      */
 103      RESOURCE_VARIABLE,
 104 
 105     /**
 106      * A module.
 107      * @since 9
 108      * @spec JPMS
 109      */
 110      MODULE,
 111 
 112     /**
 113      * A record type.
 114      * @since amber
 115      */
 116     RECORD,
 117 
 118     // Neither fish nor fowl; necessary?
 119     /**
 120      * A state component of a {@code record}.
 121      * @since amber
 122      */
 123     STATE_COMPONENT;
 124 
 125     /**
 126      * Returns {@code true} if this is a kind of class:
 127      * either {@code CLASS} or {@code ENUM} or {@code RECORD}.
 128      *
 129      * @return {@code true} if this is a kind of class
 130      */
 131     public boolean isClass() {
 132         return this == CLASS || this == ENUM || this == RECORD;
 133     }
 134 
 135     /**
 136      * Returns {@code true} if this is a kind of interface:
 137      * either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
 138      *
 139      * @return {@code true} if this is a kind of interface
 140      */
 141     public boolean isInterface() {
 142         return this == INTERFACE || this == ANNOTATION_TYPE;
 143     }
 144 
 145     /**
 146      * Returns {@code true} if this is a kind of field:
 147      * either {@code FIELD} or {@code ENUM_CONSTANT}.
 148      *
 149      * @return {@code true} if this is a kind of field
 150      */
 151     public boolean isField() {
 152         return this == FIELD || this == ENUM_CONSTANT;
< prev index next >