當前位置: 首頁>>代碼示例>>Java>>正文


Java TypeKind.isPrimitive方法代碼示例

本文整理匯總了Java中javax.lang.model.type.TypeKind.isPrimitive方法的典型用法代碼示例。如果您正苦於以下問題:Java TypeKind.isPrimitive方法的具體用法?Java TypeKind.isPrimitive怎麽用?Java TypeKind.isPrimitive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.lang.model.type.TypeKind的用法示例。


在下文中一共展示了TypeKind.isPrimitive方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTypeClass

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
private static String getTypeClass(TypeMirror type, CompilationInfo javac) {
    TypeKind kind = type.getKind();
    if (kind.isPrimitive()) {
        return type.toString();
    } else if (kind == TypeKind.ARRAY) {
        return resolveArrayClass((ArrayType) type, javac);
    } else if (kind == TypeKind.DECLARED) {
        return ((TypeElement) ((DeclaredType) type).asElement()).getQualifiedName().toString();
    } else if (kind == TypeKind.ERROR) {
        return type.toString();
    } else if (kind == TypeKind.TYPEVAR) {
        return javac.getTypes().erasure(type).toString();
    } else {
        throw new IllegalStateException("Unknown type: " + type + ", " + type.getKind()); // NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:BiFeature.java

示例2: checkPublicType

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
private void checkPublicType(ModelContext ctx, TypeMirror type, ExecutableElement method, boolean acceptVoid, String msg) throws ModelException {
	TypeKind kind = type.getKind();
	if (kind.isPrimitive()) {
		return;
	}
	switch (kind) {
		case ARRAY:
			checkPublicType(ctx, ((ArrayType) type).getComponentType(), method, false, msg);
			return;
		case DECLARED:
			if (ctx.isPublic(type) || ctx.isProtected(type)) {
				return;
			}
			throw new ModelException(msg + ": " + type + " is not public or protected");
		case VOID:
			if (acceptVoid) {
				return;
			}
			throw new ModelException(msg + ": unsupported type " + type);
		default:
			throw new ModelException(msg + ": unsupported type " + type);
	}
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:24,代碼來源:TimedMethodModel.java

示例3: testIsPrimitive

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:TestTypeKind.java

示例4: collectBuiltins

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
private void collectBuiltins(Map<String, TypeMirror> collected) {
  for (TypeKind kind : TypeKind.values()) {
    if (kind.isPrimitive()) {
      TypeElement boxedClass = types.boxedClass(types.getPrimitiveType(kind));
      collected.put(boxedClass.getSimpleName().toString(), boxedClass.asType());
    }
  }

  TypeElement typeElement = elements.getTypeElement(String.class.getCanonicalName());
  collected.put(typeElement.getSimpleName().toString(), typeElement.asType());

  typeElement = elements.getTypeElement(Templates.Invokable.class.getCanonicalName());
  collected.put(typeElement.getSimpleName().toString(), typeElement.asType());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:Imports.java

示例5: isPossibleCopyMethod

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
/**
 * Applies to both builder and value candidates.
 *
 * @param valueAttribute the valueAttribute.
 * @param possibleCopyMethod candidate to check.
 */
protected static boolean isPossibleCopyMethod(ValueAttribute valueAttribute,
    Element possibleCopyMethod, boolean onValueType) {
  if (possibleCopyMethod.getKind() == ElementKind.METHOD) {
    ExecutableElement candidateCopyMethod = (ExecutableElement) possibleCopyMethod;

    if (candidateCopyMethod.getParameters().size() == 1
        && candidateCopyMethod.getParameters().get(0).asType().equals(valueAttribute.containedTypeElement.asType())) {

      return true;
      // handle proto style toBuilder() copy method... lots of BuilderModels created because of this
    } else if (onValueType
        && candidateCopyMethod.getParameters().size() == 0
        && !candidateCopyMethod.getModifiers().contains(Modifier.STATIC)) {

      TypeKind kind = candidateCopyMethod.getReturnType().getKind();
      return !kind.isPrimitive() && kind != TypeKind.ARRAY;
    }
  } else if (!onValueType && possibleCopyMethod.getKind() == ElementKind.CONSTRUCTOR) {

    if (!valueAttribute.containingType.names().newTokenInAttributeBuilder()) {
      return false;
    }

    ExecutableElement candidateConstructor = (ExecutableElement) possibleCopyMethod;
    return candidateConstructor.getParameters().size() == 1
        && candidateConstructor.getParameters().get(0).asType().equals(valueAttribute.containedTypeElement.asType());
  }

  return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:37,代碼來源:AttributeBuilderReflection.java

示例6: lookupType

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
private static TypeMirror lookupType(ProcessingEnvironment env, String binaryName) {
    if (binaryName.length() == 1) {
        TypeKind kind = fromPrimitiveOrVoidTypeChar(binaryName.charAt(0));
        if (kind.isPrimitive()) {
            return env.getTypeUtils().getPrimitiveType(kind);
        } else if (kind == TypeKind.VOID) {
            return env.getTypeUtils().getNoType(kind);
        }
    }

    String canonicalName = binaryName;
    if (canonicalName.startsWith("L") && canonicalName.endsWith(";")) {
        canonicalName = canonicalName.substring(1, canonicalName.length() - 1);
    }
    env.getMessager().printMessage(Kind.ERROR, canonicalName);

    int arrayDims = 0;
    while (canonicalName.startsWith("[")) {
        canonicalName = canonicalName.substring(1, canonicalName.length());
        arrayDims++;
    }

    canonicalName = canonicalName.replaceAll("/", ".");
    TypeElement typeElement = env.getElementUtils().getTypeElement(canonicalName);
    if (typeElement == null) {
        throw new RuntimeException(String.format("Type with name %s not found.", canonicalName));
    }
    TypeMirror mirror = typeElement.asType();
    for (int i = 0; i < arrayDims; i++) {
        mirror = env.getTypeUtils().getArrayType(mirror);
    }
    return mirror;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:APHotSpotSignature.java

示例7: isNumberType

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
public boolean isNumberType() {
  TypeKind kind = returnType.getKind();
  return kind.isPrimitive()
      && kind != TypeKind.CHAR
      && kind != TypeKind.BOOLEAN;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:ValueAttribute.java

示例8: isPrimitiveType

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
private static boolean isPrimitiveType(TypeKind k) {
    return k.isPrimitive();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:ExpectedTypeResolver.java

示例9: PrimitiveTypeDesc

import javax.lang.model.type.TypeKind; //導入方法依賴的package包/類
public PrimitiveTypeDesc(TypeKind typeKind) {
    super(typeKind);
    if (!typeKind.isPrimitive() && typeKind != TypeKind.VOID)
        throw new IllegalArgumentException("Only primitives or void accepted");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:PrimitiveTypeDesc.java


注:本文中的javax.lang.model.type.TypeKind.isPrimitive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。