本文整理匯總了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;
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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));
}
示例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());
}
}
示例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;
}
示例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());
}
}
示例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;
}
示例11: PrimitiveTypeMoniker
import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
public PrimitiveTypeMoniker(PrimitiveType type) {
kind = type.getKind();
}
示例12: matches
import javax.lang.model.type.PrimitiveType; //導入方法依賴的package包/類
@Override
public boolean matches(PrimitiveType type) {
return type.getKind() == TypeKind.INT;
}