Java Code Examples for javax.lang.model.type.TypeKind#FLOAT
The following examples show how to use
javax.lang.model.type.TypeKind#FLOAT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeTag.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (this) { case BOOLEAN: return TypeKind.BOOLEAN; case BYTE: return TypeKind.BYTE; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case CHAR: return TypeKind.CHAR; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 2
Source File: JCTree.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (typetag) { case TypeTags.BOOLEAN: return TypeKind.BOOLEAN; case TypeTags.BYTE: return TypeKind.BYTE; case TypeTags.SHORT: return TypeKind.SHORT; case TypeTags.INT: return TypeKind.INT; case TypeTags.LONG: return TypeKind.LONG; case TypeTags.CHAR: return TypeKind.CHAR; case TypeTags.FLOAT: return TypeKind.FLOAT; case TypeTags.DOUBLE: return TypeKind.DOUBLE; case TypeTags.VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 3
Source File: Type.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public TypeKind getKind() { switch (tag) { case BYTE: return TypeKind.BYTE; case CHAR: return TypeKind.CHAR; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case BOOLEAN: return TypeKind.BOOLEAN; case VOID: return TypeKind.VOID; case BOT: return TypeKind.NULL; case NONE: return TypeKind.NONE; default: return TypeKind.OTHER; } }
Example 4
Source File: TypeTag.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (this) { case BOOLEAN: return TypeKind.BOOLEAN; case BYTE: return TypeKind.BYTE; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case CHAR: return TypeKind.CHAR; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 5
Source File: TypeTag.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (this) { case BOOLEAN: return TypeKind.BOOLEAN; case BYTE: return TypeKind.BYTE; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case CHAR: return TypeKind.CHAR; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 6
Source File: StructProcess.java From Mindustry with GNU General Public License v3.0 | 6 votes |
static int varSize(VariableElement var) throws IllegalArgumentException{ if(!var.asType().getKind().isPrimitive()){ throw new IllegalArgumentException("All struct fields must be primitives: " + var); } StructField an = var.getAnnotation(StructField.class); if(var.asType().getKind() == TypeKind.BOOLEAN && an != null && an.value() != 1){ throw new IllegalArgumentException("Booleans can only be one bit long... why would you do this?"); } if(var.asType().getKind() == TypeKind.FLOAT && an != null && an.value() != 32){ throw new IllegalArgumentException("Float size can't be changed. Very sad."); } return an == null ? typeSize(var.asType().getKind()) : an.value(); }
Example 7
Source File: Type.java From javaide with GNU General Public License v3.0 | 6 votes |
public TypeKind getKind() { switch (tag) { case BYTE: return TypeKind.BYTE; case CHAR: return TypeKind.CHAR; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case BOOLEAN: return TypeKind.BOOLEAN; case VOID: return TypeKind.VOID; case BOT: return TypeKind.NULL; case NONE: return TypeKind.NONE; default: return TypeKind.OTHER; } }
Example 8
Source File: APHotSpotSignature.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns the kind from the character describing a primitive or void. * * @param ch the character * @return the kind */ public static TypeKind fromPrimitiveOrVoidTypeChar(char ch) { switch (ch) { case 'Z': return TypeKind.BOOLEAN; case 'C': return TypeKind.CHAR; case 'F': return TypeKind.FLOAT; case 'D': return TypeKind.DOUBLE; case 'B': return TypeKind.BYTE; case 'S': return TypeKind.SHORT; case 'I': return TypeKind.INT; case 'J': return TypeKind.LONG; case 'V': return TypeKind.VOID; } throw new IllegalArgumentException("unknown primitive or void type character: " + ch); }
Example 9
Source File: JCTree.java From javaide with GNU General Public License v3.0 | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (typetag) { case TypeTags.BOOLEAN: return TypeKind.BOOLEAN; case TypeTags.BYTE: return TypeKind.BYTE; case TypeTags.SHORT: return TypeKind.SHORT; case TypeTags.INT: return TypeKind.INT; case TypeTags.LONG: return TypeKind.LONG; case TypeTags.CHAR: return TypeKind.CHAR; case TypeTags.FLOAT: return TypeKind.FLOAT; case TypeTags.DOUBLE: return TypeKind.DOUBLE; case TypeTags.VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 10
Source File: TypeTag.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (this) { case BOOLEAN: return TypeKind.BOOLEAN; case BYTE: return TypeKind.BYTE; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case CHAR: return TypeKind.CHAR; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 11
Source File: TypeTag.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public TypeKind getPrimitiveTypeKind() { switch (this) { case BOOLEAN: return TypeKind.BOOLEAN; case BYTE: return TypeKind.BYTE; case SHORT: return TypeKind.SHORT; case INT: return TypeKind.INT; case LONG: return TypeKind.LONG; case CHAR: return TypeKind.CHAR; case FLOAT: return TypeKind.FLOAT; case DOUBLE: return TypeKind.DOUBLE; case VOID: return TypeKind.VOID; default: throw new AssertionError("unknown primitive type " + this); } }
Example 12
Source File: TypeUtil.java From j2objc with Apache License 2.0 | 6 votes |
/** * If either type is a double TypeMirror, a double TypeMirror is returned. * Otherwise, if either type is a float TypeMirror, a float TypeMirror is returned. * Otherwise, if either type is a long TypeMirror, a long TypeMirror is returned. * Otherwise, an int TypeMirror is returned. See jls-5.6.2. * @param type1 a numeric type * @param type2 a numeric type * @return the result of binary numeric promotion applied to type1 and type2 */ public TypeMirror binaryNumericPromotion(TypeMirror type1, TypeMirror type2) { TypeKind t1 = type1.getKind(); TypeKind t2 = type2.getKind(); if (t1 == TypeKind.DECLARED) { t1 = javacTypes.unboxedType(type1).getKind(); } if (t2 == TypeKind.DECLARED) { t2 = javacTypes.unboxedType(type2).getKind(); } if (t1 == TypeKind.DOUBLE || t2 == TypeKind.DOUBLE) { return getDouble(); } else if (t1 == TypeKind.FLOAT || t2 == TypeKind.FLOAT) { return getFloat(); } else if (t1 == TypeKind.LONG || t2 == TypeKind.LONG) { return getLong(); } else { return getInt(); } }
Example 13
Source File: PrimitiveTypeImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static TypeKind getKind(BaseTypeBinding binding) { switch (binding.id) { case TypeIds.T_boolean: return TypeKind.BOOLEAN; case TypeIds.T_byte: return TypeKind.BYTE; case TypeIds.T_char: return TypeKind.CHAR; case TypeIds.T_double: return TypeKind.DOUBLE; case TypeIds.T_float: return TypeKind.FLOAT; case TypeIds.T_int: return TypeKind.INT; case TypeIds.T_long: return TypeKind.LONG; case TypeIds.T_short: return TypeKind.SHORT; default: throw new IllegalArgumentException("BaseTypeBinding of unexpected id " + binding.id); //$NON-NLS-1$ } }
Example 14
Source File: AddWsOperationHelper.java From netbeans with Apache License 2.0 | 6 votes |
private String getMethodBody(Tree returnType) { String body = null; if (Kind.PRIMITIVE_TYPE == returnType.getKind()) { TypeKind type = ((PrimitiveTypeTree)returnType).getPrimitiveTypeKind(); if (TypeKind.VOID == type) body = ""; //NOI18N else if (TypeKind.BOOLEAN == type) body = "return false;"; // NOI18N else if (TypeKind.INT == type) body = "return 0;"; // NOI18N else if (TypeKind.LONG == type) body = "return 0;"; // NOI18N else if (TypeKind.FLOAT == type) body = "return 0.0;"; // NOI18N else if (TypeKind.DOUBLE == type) body = "return 0.0;"; // NOI18N else if (TypeKind.BYTE == type) body = "return 0;"; // NOI18N else if (TypeKind.SHORT == type) body = "return 0;"; // NOI18N else if (TypeKind.CHAR == type) body = "return ' ';"; // NOI18N else body = "return null"; //NOI18N } else body = "return null"; //NOI18N return "{\n\t\t"+NbBundle.getMessage(AddWsOperationHelper.class, "TXT_TodoComment")+"\n"+body+"\n}"; }
Example 15
Source File: TypeUtils.java From alchemy with Apache License 2.0 | 5 votes |
boolean isDoubleFamily(TypeMirror type) { try { TypeKind typeKind = type.getKind(); if (TypeKind.DECLARED == typeKind) { typeKind = unbox(type).getKind(); } return TypeKind.DOUBLE == typeKind || TypeKind.FLOAT == typeKind; } catch (IllegalArgumentException ignored) { return false; } }
Example 16
Source File: GenerationUtils.java From netbeans with Apache License 2.0 | 5 votes |
public Tree createType(String typeName, TypeElement scope) { TreeMaker make = getTreeMaker(); TypeKind primitiveTypeKind = null; if ("boolean".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.BOOLEAN; } else if ("byte".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.BYTE; } else if ("short".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.SHORT; } else if ("int".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.INT; } else if ("long".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.LONG; } else if ("char".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.CHAR; } else if ("float".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.FLOAT; } else if ("double".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.DOUBLE; } else if ("void".equals(typeName)) { // NOI18N primitiveTypeKind = TypeKind.VOID; } if (primitiveTypeKind != null) { return getTreeMaker().PrimitiveType(primitiveTypeKind); } Tree typeTree = tryCreateQualIdent(typeName); if (typeTree == null) { // XXX does not handle imports; temporary until issue 102149 is fixed TypeMirror typeMirror = copy.getTreeUtilities().parseType(typeName, scope); typeTree = make.Type(typeMirror); } return typeTree; }
Example 17
Source File: AddWsOperationHelper.java From netbeans with Apache License 2.0 | 5 votes |
private String getMethodBody(Tree returnType) { String body = null; if (Kind.PRIMITIVE_TYPE == returnType.getKind()) { TypeKind type = ((PrimitiveTypeTree)returnType).getPrimitiveTypeKind(); if (TypeKind.VOID == type) { body = ""; //NOI18N } else if (TypeKind.BOOLEAN == type) { body = "return false;"; // NOI18N } else if (TypeKind.INT == type) { body = "return 0;"; // NOI18N } else if (TypeKind.LONG == type) { body = "return 0;"; // NOI18N } else if (TypeKind.FLOAT == type) { body = "return 0.0;"; // NOI18N } else if (TypeKind.DOUBLE == type) { body = "return 0.0;"; // NOI18N } else if (TypeKind.BYTE == type) { body = "return 0;"; // NOI18N } else if (TypeKind.SHORT == type) { body = "return 0;"; // NOI18N } else if (TypeKind.CHAR == type) { body = "return ' ';"; // NOI18N } else { body = "return null"; //NOI18N } } else body = "return null"; //NOI18N return "{\n\t\t"+NbBundle.getMessage(AddWsOperationHelper.class, "TXT_TodoComment")+"\n"+body+"\n}"; }
Example 18
Source File: ButterKnifeProcessor.java From butterknife with Apache License 2.0 | 5 votes |
private void parseResourceDimen(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is int or ColorStateList. boolean isInt = false; TypeMirror elementType = element.asType(); if (elementType.getKind() == TypeKind.INT) { isInt = true; } else if (elementType.getKind() != TypeKind.FLOAT) { error(element, "@%s field type must be 'int' or 'float'. (%s.%s)", BindDimen.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindDimen.class, "fields", element); hasError |= isBindingInWrongPackage(BindDimen.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindDimen.class).value(); Id resourceId = elementToId(element, BindDimen.class, id); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource(new FieldResourceBinding(resourceId, name, isInt ? FieldResourceBinding.Type.DIMEN_AS_INT : FieldResourceBinding.Type.DIMEN_AS_FLOAT)); erasedTargetNames.add(enclosingElement); }
Example 19
Source File: TypeUtil.java From j2objc with Apache License 2.0 | 4 votes |
public static boolean isFloatingPoint(TypeMirror t) { TypeKind kind = t.getKind(); return kind == TypeKind.FLOAT || kind == TypeKind.DOUBLE; }
Example 20
Source File: TypeUtils.java From ig-json-parser with MIT License | 4 votes |
public ParseType getParseType( TypeMirror typeMirror, @Nullable Class<? extends Annotation> typeAnnotationClass) { if (typeMirror == null) { return ParseType.UNSUPPORTED; } else if (JAVA_LANG_STRING.equals(typeMirror.toString())) { return ParseType.STRING; } else if (typeMirror.getKind() == TypeKind.BOOLEAN) { return ParseType.BOOLEAN; } else if (JAVA_LANG_BOOLEAN.equals(typeMirror.toString())) { return ParseType.BOOLEAN_OBJECT; } else if (typeMirror.getKind() == TypeKind.INT) { return ParseType.INTEGER; } else if (JAVA_LANG_INTEGER.equals(typeMirror.toString())) { return ParseType.INTEGER_OBJECT; } else if (typeMirror.getKind() == TypeKind.LONG) { return ParseType.LONG; } else if (JAVA_LANG_LONG.equals(typeMirror.toString())) { return ParseType.LONG_OBJECT; } else if (typeMirror.getKind() == TypeKind.FLOAT) { return ParseType.FLOAT; } else if (JAVA_LANG_FLOAT.equals(typeMirror.toString())) { return ParseType.FLOAT_OBJECT; } else if (typeMirror.getKind() == TypeKind.DOUBLE) { return ParseType.DOUBLE; } else if (JAVA_LANG_DOUBLE.equals(typeMirror.toString())) { return ParseType.DOUBLE_OBJECT; } else if (typeMirror instanceof DeclaredType) { DeclaredType type = (DeclaredType) typeMirror; Element element = type.asElement(); Annotation annotation = typeAnnotationClass != null ? element.getAnnotation(typeAnnotationClass) : null; if (annotation != null && EnumSet.of(CLASS, INTERFACE).contains(element.getKind())) { return ParseType.PARSABLE_OBJECT; } // is it an enum? if (element instanceof TypeElement) { TypeElement typeElement = (TypeElement) element; TypeMirror superclass = typeElement.getSuperclass(); if (superclass instanceof DeclaredType) { DeclaredType superclassDeclaredType = (DeclaredType) superclass; if (JAVA_LANG_ENUM.equals(getCanonicalTypeName(superclassDeclaredType))) { return ParseType.ENUM_OBJECT; } } } } return ParseType.UNSUPPORTED; }