当前位置: 首页>>代码示例>>Java>>正文


Java TypeKind.INT属性代码示例

本文整理汇总了Java中javax.lang.model.type.TypeKind.INT属性的典型用法代码示例。如果您正苦于以下问题:Java TypeKind.INT属性的具体用法?Java TypeKind.INT怎么用?Java TypeKind.INT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.lang.model.type.TypeKind的用法示例。


在下文中一共展示了TypeKind.INT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unboxBoxed

/**
 * Unbox a wrapper type into a TypeKind. Some additional types are mapped to TypeKinds which cannot really appear in 
 * expressions (at least I hope)
 * 
 * @param tm
 * @return 
 */
private static TypeKind unboxBoxed(TypeMirror tm) {
    TypeElement te = (TypeElement)((DeclaredType)tm).asElement();
    String qn = te.getQualifiedName().toString();
    if (!qn.startsWith("java.lang.")) { // NO18N
        if (qn.equals("java.math.BigInteger")) { // NOI18N
            return TypeKind.WILDCARD;
        }
        return null;
    }
    switch (qn.substring(10)) {
        case "Short": return TypeKind.SHORT; // NOI18N
        case "Long": return TypeKind.LONG; // NOI18N
        case "Byte": return TypeKind.BYTE; // NOI18N
        case "Integer": return TypeKind.INT; // NOI18N
        case "Double": return TypeKind.DOUBLE; // NOI18N
        case "Float": return TypeKind.FLOAT; // NOI18N
        case "Character": return TypeKind.CHAR; // NOI18N
        case "String": return TypeKind.OTHER; // NOI18N
        case "Object": return TypeKind.PACKAGE; // NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:MalformedFormatString.java

示例2: getPrimitiveTypeKind

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);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:JCTree.java

示例3: getKind

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;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:16,代码来源:Type.java

示例4: getPrimitiveTypeKind

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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:TypeTag.java

示例5: fromPrimitiveOrVoidTypeChar

/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:APHotSpotSignature.java

示例6: getDummyInner1

private static PubType getDummyInner1() {
    PubMethod init = new PubMethod(setOf(),
                                   emptyList(),
                                   new PrimitiveTypeDesc(TypeKind.VOID),
                                   "<init>",
                                   emptyList(),
                                   emptyList());

    PubMethod run = new PubMethod(setOf(PUBLIC),
                                  emptyList(),
                                  new PrimitiveTypeDesc(TypeKind.VOID),
                                  "run",
                                  emptyList(),
                                  emptyList());

    PubVar field = new PubVar(setOf(PROTECTED),
                              new PrimitiveTypeDesc(TypeKind.INT),
                              "field",
                              null);

    return new PubType(setOf(STATIC),
                       "TestClass$DummyInner1",
                       new PubApi(emptyList(),
                                  asList(field),
                                  asList(init, run)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ApiExtraction.java

示例7: parseResourceColor

private void parseResourceColor(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 isColorStateList = false;
  TypeMirror elementType = element.asType();
  if (COLOR_STATE_LIST_TYPE.equals(elementType.toString())) {
    isColorStateList = true;
  } else if (elementType.getKind() != TypeKind.INT) {
    error(element, "@%s field type must be 'int' or 'ColorStateList'. (%s.%s)",
        BindColor.class.getSimpleName(), enclosingElement.getQualifiedName(),
        element.getSimpleName());
    hasError = true;
  }

  // Verify common generated code restrictions.
  hasError |= isInaccessibleViaGeneratedCode(BindColor.class, "fields", element);
  hasError |= isBindingInWrongPackage(BindColor.class, element);

  if (hasError) {
    return;
  }

  // Assemble information on the field.
  String name = element.getSimpleName().toString();
  int id = element.getAnnotation(BindColor.class).value();
  QualifiedId qualifiedId = elementToQualifiedId(element, id);
  BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement);
  builder.addResource(new FieldResourceBinding(getId(qualifiedId), name,
      isColorStateList ? FieldResourceBinding.Type.COLOR_STATE_LIST
          : FieldResourceBinding.Type.COLOR));

  erasedTargetNames.add(enclosingElement);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:ButterKnifeProcessor.java

示例8: parseResourceDimen

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();
  QualifiedId qualifiedId = elementToQualifiedId(element, id);
  BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement);
  builder.addResource(new FieldResourceBinding(getId(qualifiedId), name,
      isInt ? FieldResourceBinding.Type.DIMEN_AS_INT : FieldResourceBinding.Type.DIMEN_AS_FLOAT));

  erasedTargetNames.add(enclosingElement);
}
 
开发者ID:qq542391099,项目名称:butterknife-parent,代码行数:35,代码来源:ButterKnifeProcessor.java

示例9: parseResourceInt

private void parseResourceInt(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.
  if (element.asType().getKind() != TypeKind.INT) {
    error(element, "@%s field type must be 'int'. (%s.%s)", BindInt.class.getSimpleName(),
        enclosingElement.getQualifiedName(), element.getSimpleName());
    hasError = true;
  }

  // Verify common generated code restrictions.
  hasError |= isInaccessibleViaGeneratedCode(BindInt.class, "fields", element);
  hasError |= isBindingInWrongPackage(BindInt.class, element);

  if (hasError) {
    return;
  }

  // Assemble information on the field.
  String name = element.getSimpleName().toString();
  int id = element.getAnnotation(BindInt.class).value();
  QualifiedId qualifiedId = elementToQualifiedId(element, id);
  BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement);
  builder.addResource(
      new FieldResourceBinding(getId(qualifiedId), name, FieldResourceBinding.Type.INT));

  erasedTargetNames.add(enclosingElement);
}
 
开发者ID:qq542391099,项目名称:butterknife-parent,代码行数:30,代码来源:ButterKnifeProcessor.java

示例10: addMembers

private void addMembers(TypeElement source, GeneratorUtilities genUtils, List<Tree> members) throws IllegalStateException {
    for (ExecutableElement method : ElementFilter.methodsIn(workingCopy.getElements().getAllMembers(source))) {
        if (!method.getModifiers().contains(Modifier.NATIVE)
                && method.getModifiers().contains(Modifier.PUBLIC)
                && !method.getEnclosingElement().equals(workingCopy.getElements().getTypeElement("java.lang.Object"))) { //NOI18N
            if (!((method.getReturnType().getKind() == TypeKind.BOOLEAN && method.getSimpleName().contentEquals("equals")) || //NOI18N
                    (method.getReturnType().getKind() == TypeKind.INT && method.getSimpleName().contentEquals("hashCode")))) { //NOI18N
                addMember(source, method, genUtils, members);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:IntroduceLocalExtensionTransformer.java

示例11: createType

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 = makeQualIdent(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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:GenerationUtils.java

示例12: after

@TriggerPattern(value="$mods$ $type $name = $init$;")
public static ErrorDescription after(HintContext ctx) {
    if (testElement(ctx) == null) return null;

    TreePath init = ctx.getVariables().get("$init$");

    if (init != null) {
        if (init.getLeaf().getKind() != Kind.NEW_CLASS) return null;

        NewClassTree nct = (NewClassTree) init.getLeaf();

        if (nct.getClassBody() != null || nct.getArguments().size() > 1) return null;

        if (nct.getArguments().size() == 1) {
            TypeMirror tm = ctx.getInfo().getTrees().getTypeMirror(new TreePath(init, nct.getArguments().get(0)));

            if (tm == null || tm.getKind() != TypeKind.INT) return null;
        }
    }

    if (   ctx.getPath().getParentPath().getLeaf().getKind() == Kind.ENHANCED_FOR_LOOP
        && ((EnhancedForLoopTree) ctx.getPath().getParentPath().getLeaf()).getVariable() == ctx.getPath().getLeaf()) {
        return null;
    }
    
    return produceWarning(ctx, "ERR_UnbalancedCollection");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Unbalanced.java

示例13: createType

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);
        if ( typeMirror == null || typeMirror.getKind() == TypeKind.ERROR ){
            typeTree = getTreeMaker().QualIdent( typeName );
        }
        else {
            typeTree = make.Type(typeMirror);
        }
    }
    return typeTree;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:GenerationUtils.java

示例14: isInt

public boolean isInt() {
  return returnType.getKind() == TypeKind.INT;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:3,代码来源:ValueAttribute.java

示例15: fieldTypeFor

public static FieldType fieldTypeFor(TypeMirror typeMirror, TypeMirror typeConverterType, Elements elements, Types types) {
    if (typeMirror != null) {
        if (typeConverterType != null && !"void".equals(typeConverterType.toString())) {
            return new TypeConverterFieldType(TypeName.get(typeMirror), ClassName.bestGuess(typeConverterType.toString()));
        } else if (typeMirror.getKind() == TypeKind.BOOLEAN) {
            return new BooleanFieldType(true);
        } else if (Boolean.class.getCanonicalName().equals(typeMirror.toString())) {
            return new BooleanFieldType(false);
        } else if (typeMirror.getKind() == TypeKind.BYTE) {
            return new ByteFieldType(true);
        } else if (Byte.class.getCanonicalName().equals(typeMirror.toString())) {
            return new ByteFieldType(false);
        } else if (typeMirror.getKind() == TypeKind.INT) {
            return new IntegerFieldType(true);
        } else if (Integer.class.getCanonicalName().equals(typeMirror.toString())) {
            return new IntegerFieldType(false);
        } else if (typeMirror.getKind() == TypeKind.LONG) {
            return new LongFieldType(true);
        } else if (Long.class.getCanonicalName().equals(typeMirror.toString())) {
            return new LongFieldType(false);
        } else if (typeMirror.getKind() == TypeKind.FLOAT) {
            return new FloatFieldType(true);
        } else if (Float.class.getCanonicalName().equals(typeMirror.toString())) {
            return new FloatFieldType(false);
        } else if (typeMirror.getKind() == TypeKind.DOUBLE) {
            return new DoubleFieldType(true);
        } else if (Double.class.getCanonicalName().equals(typeMirror.toString())) {
            return new DoubleFieldType(false);
        } else if (String.class.getCanonicalName().equals(typeMirror.toString())) {
            return new StringFieldType();
        } else if (Object.class.getCanonicalName().equals(typeMirror.toString())) {
            return new UnknownFieldType();
        } else if (typeMirror instanceof DeclaredType) {
            Annotation annotation = ((DeclaredType) typeMirror).asElement().getAnnotation(JsonObject.class);
            if (annotation != null) {
                return new JsonFieldType(ClassName.bestGuess(typeMirror.toString()));
            }
        }

        return new DynamicFieldType(TypeName.get(typeMirror));
    } else {
        return null;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:FieldType.java


注:本文中的javax.lang.model.type.TypeKind.INT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。