1 /* 2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.lang.model.type; 27 28 29 /** 30 * The kind of a type mirror. 31 * 32 * <p>Note that it is possible additional type kinds will be added to 33 * accommodate new, currently unknown, language structures added to 34 * future versions of the Java™ programming language. 35 * 36 * @author Joseph D. Darcy 37 * @author Scott Seligman 38 * @author Peter von der Ahé 39 * @see TypeMirror 40 * @since 1.6 41 */ 42 public enum TypeKind { 43 /** 44 * The primitive type {@code boolean}. 45 */ 46 BOOLEAN, 47 48 /** 49 * The primitive type {@code byte}. 50 */ 51 BYTE, 52 53 /** 54 * The primitive type {@code short}. 55 */ 56 SHORT, 57 58 /** 59 * The primitive type {@code int}. 60 */ 61 INT, 62 63 /** 64 * The primitive type {@code long}. 65 */ 66 LONG, 67 68 /** 69 * The primitive type {@code char}. 70 */ 71 CHAR, 72 73 /** 74 * The primitive type {@code float}. 75 */ 76 FLOAT, 77 78 /** 79 * The primitive type {@code double}. 80 */ 81 DOUBLE, 82 83 /** 84 * The pseudo-type corresponding to the keyword {@code void}. 85 * @see NoType 86 */ 87 VOID, 88 89 /** 90 * A pseudo-type used where no actual type is appropriate. 91 * @see NoType 92 */ 93 NONE, 94 95 /** 96 * The null type. 97 */ 98 NULL, 99 100 /** 101 * An array type. 102 */ 103 ARRAY, 104 105 /** 106 * A class or interface type. 107 */ 108 DECLARED, 109 110 /** 111 * A class or interface type that could not be resolved. 112 */ 113 ERROR, 114 115 /** 116 * A type variable. 117 */ 118 TYPEVAR, 119 120 /** 121 * A wildcard type argument. 122 */ 123 WILDCARD, 124 125 /** 126 * A pseudo-type corresponding to a package element. 127 * @see NoType 128 */ 129 PACKAGE, 130 131 /** 132 * A method, constructor, or initializer. 133 */ 134 EXECUTABLE, 135 136 /** 137 * An implementation-reserved type. 138 * This is not the type you are looking for. 139 */ 140 OTHER, 141 142 /** 143 * A union type. 144 * 145 * @since 1.7 146 */ 147 UNION, 148 149 /** 150 * An intersection type. 151 * 152 * @since 1.8 153 */ 154 INTERSECTION, 155 156 /** 157 * A pseudo-type corresponding to a module element. 158 * @see NoType 159 * @since 9 160 * @spec JPMS 161 */ 162 MODULE; 163 164 /** 165 * Returns {@code true} if this kind corresponds to a primitive 166 * type and {@code false} otherwise. 167 * @return {@code true} if this kind corresponds to a primitive type 168 */ 169 public boolean isPrimitive() { 170 switch(this) { 171 case BOOLEAN: 172 case BYTE: 173 case SHORT: 174 case INT: 175 case LONG: 176 case CHAR: 177 case FLOAT: 178 case DOUBLE: 179 return true; 180 181 default: 182 return false; 183 } 184 } 185 }