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


Java PrimitiveType.getKind方法代碼示例

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


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

示例1: writePrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
private void writePrimitive(CodeBlock.Builder builder, Object name, PrimitiveType type) {
    switch (type.getKind()) {
        case LONG:
            builder.addStatement("$N.writeLong($L)", parcelName, name);
            break;
        case DOUBLE:
            builder.addStatement("$L.writeDouble($L)", parcelName, name);
            break;
        case FLOAT:
            builder.addStatement("$L.writeFloat($L)", parcelName, name);
            break;
        case BOOLEAN:
            builder.addStatement("$L.writeInt($L ? 1 : 0)", parcelName, name);
            break;
        default:
            builder.addStatement("$L.writeInt($L)", parcelName, name);
            break;
    }
}
 
開發者ID:chdir,項目名稱:aidl2,代碼行數:20,代碼來源:Writer.java

示例2: readPrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
private CodeBlock readPrimitive(PrimitiveType type) {
    switch (type.getKind()) {
        case LONG:
            return literal("$N.readLong()", parcelName);
        case DOUBLE:
            return literal("$N.readDouble()", parcelName);
        case FLOAT:
            return literal("$N.readFloat()", parcelName);
        case BOOLEAN:
            return literal("$N.readInt() == 1", parcelName);
        case INT:
            return literal("$N.readInt()", parcelName);
        default:
            return literal("($T) $N.readInt()", type, parcelName);
    }
}
 
開發者ID:chdir,項目名稱:aidl2,代碼行數:17,代碼來源:Reader.java

示例3: visitPrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
@Override
public String visitPrimitive(PrimitiveType t, Void p) {
	switch (t.getKind()) {
	case BOOLEAN:
		return Boolean.class.getName();
	case BYTE:
		return Byte.class.getName();
	case CHAR:
		return Character.class.getName();
	case DOUBLE:
		return Double.class.getName();
	case FLOAT:
		return Float.class.getName();
	case INT:
		return Integer.class.getName();
	case LONG:
		return Long.class.getName();
	case SHORT:
		return Short.class.getName();
	default:
		throw new IllegalStateException();
	}
}
 
開發者ID:guicamest,項目名稱:bsoneer,代碼行數:24,代碼來源:TypeResolver.java

示例4: visitPrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
@Override
public Class<?> visitPrimitive(PrimitiveType t, Void p) {
    switch (t.getKind()) {
    case BOOLEAN:
        return BooleanWrapper.class;
    case BYTE:
        return ByteWrapper.class;
    case SHORT:
        return ShortWrapper.class;
    case INT:
        return IntegerWrapper.class;
    case LONG:
        return LongWrapper.class;
    case FLOAT:
        return FloatWrapper.class;
    case DOUBLE:
        return DoubleWrapper.class;
    case CHAR:
        return null;
    default:
        return assertUnreachable();
    }
}
 
開發者ID:domaframework,項目名稱:doma,代碼行數:24,代碼來源:WrapperCtType.java

示例5: box

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
private static Class<?> box(PrimitiveType primitiveType) {
  switch (primitiveType.getKind()) {
    case BYTE:
      return Byte.class;
    case SHORT:
      return Short.class;
    case INT:
      return Integer.class;
    case LONG:
      return Long.class;
    case FLOAT:
      return Float.class;
    case DOUBLE:
      return Double.class;
    case BOOLEAN:
      return Boolean.class;
    case CHAR:
      return Character.class;
    case VOID:
      return Void.class;
    default:
      throw new AssertionError();
  }
}
 
開發者ID:adecker89,項目名稱:Glowplug,代碼行數:25,代碼來源:Util.java

示例6: getPrimitiveArrayStrategy

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
private Strategy getPrimitiveArrayStrategy(PrimitiveType component) {
    final TypeKind componentKind = component.getKind();

    final CodeBlock block;

    switch (componentKind) {
        case BYTE:
            block = literal("$N.createByteArray()", parcelName);
            break;
        case INT:
            block = literal("$N.createIntArray()", parcelName);
            break;
        case BOOLEAN:
            block = literal("$N.createBooleanArray()", parcelName);
            break;
        case CHAR:
            block = literal("$N.createCharArray()", parcelName);
            break;
        case LONG:
            block = literal("$N.createLongArray()", parcelName);
            break;
        case DOUBLE:
            block = literal("$N.createDoubleArray()", parcelName);
            break;
        case FLOAT:
            block = literal("$N.createFloatArray()", parcelName);
            break;
        default:
            return getSerializableStrategy(types.getArrayType(component));
    }

    return new PrimitiveArrayStrategy(init -> block, types.getArrayType(component));
}
 
開發者ID:chdir,項目名稱:aidl2,代碼行數:34,代碼來源:Reader.java

示例7: toPrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
public static Class<?> toPrimitive(PrimitiveType primitiveType) {
	switch (primitiveType.getKind()) {
	case BOOLEAN: 	return Boolean.TYPE;
	case BYTE: 		return Byte.TYPE;
	case CHAR: 		return Character.TYPE;
	case DOUBLE: 	return Double.TYPE;
	case FLOAT: 	return Float.TYPE;
	case INT: 		return Integer.TYPE;
	case LONG: 		return Long.TYPE;
	case SHORT: 	return Short.TYPE;
	default:
		throw new IllegalArgumentException("Cannot map to primitive: " + primitiveType.getKind());
	}
}
 
開發者ID:joakimsahlstrom,項目名稱:twyn,代碼行數:15,代碼來源:PrimitiveTypeMap.java

示例8: visitPrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
@Override
public Void visitPrimitive(PrimitiveType t, StringBuilderAndState<TypeMirror> state) {
    switch (t.getKind()) {
    case BOOLEAN:
        state.bld.append("boolean");
        break;
    case BYTE:
        state.bld.append("byte");
        break;
    case CHAR:
        state.bld.append("char");
        break;
    case DOUBLE:
        state.bld.append("double");
        break;
    case FLOAT:
        state.bld.append("float");
        break;
    case INT:
        state.bld.append("int");
        break;
    case LONG:
        state.bld.append("long");
        break;
    case SHORT:
        state.bld.append("short");
        break;
    default:
        break;
    }

    return null;
}
 
開發者ID:revapi,項目名稱:revapi,代碼行數:34,代碼來源:Util.java

示例9: initLiteral

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
public String initLiteral(TypeMirror type) {
  if (!(type instanceof PrimitiveType)) {
    return "null";
  }

  final PrimitiveType p = (PrimitiveType) type;
  switch (p.getKind()) {
    case BOOLEAN:
      return "false";
    case SHORT:
      return "0";
    case INT:
      return "0";
    case LONG:
      return "0L";
    case FLOAT:
      return "0f";
    case DOUBLE:
      return "0d";
    case BYTE:
      return "0";
    case CHAR:
      return "'\0'";
    default:
      throw new IllegalArgumentException("Unsupported primitive: " + type.toString());
  }
}
 
開發者ID:udoprog,項目名稱:tiny-serializer-java,代碼行數:28,代碼來源:AutoSerializeUtils.java

示例10: visitPrimitive

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
@Override
public Void visitPrimitive(PrimitiveType t, Void p) {
    switch ( t.getKind() ) {
        case BOOLEAN:
            buf.append('Z');
            break;
        case BYTE:
            buf.append('B');
            break;
        case SHORT:
            buf.append('S');
            break;
        case INT:
            buf.append('I');
            break;
        case LONG:
            buf.append('J');
            break;
        case CHAR:
            buf.append('C');
            break;
        case FLOAT:
            buf.append('F');
            break;
        case DOUBLE:
            buf.append('D');
            break;
        case VOID:
            buf.append('V');
            break;
        default:
            return defaultAction(t, p);
    }
    return null;
}
 
開發者ID:Abnaxos,項目名稱:contracts,代碼行數:36,代碼來源:ParameterMapAnnotationProcessor.java

示例11: PrimitiveTypeMoniker

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
public PrimitiveTypeMoniker(PrimitiveType type) {
    kind = type.getKind();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:TypeMonikerFactory.java

示例12: matches

import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
@Override
public boolean matches(PrimitiveType type) {
  return type.getKind() == TypeKind.INT;
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:5,代碼來源:Marshallers.java


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