当前位置: 首页>>代码示例>>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;未经允许,请勿转载。