Java Code Examples for javax.lang.model.type.PrimitiveType#getKind()
The following examples show how to use
javax.lang.model.type.PrimitiveType#getKind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoreTypes.java From auto with Apache License 2.0 | 6 votes |
@Override public Boolean visitPrimitive(PrimitiveType type, Void p) { switch (type.getKind()) { case BOOLEAN: return clazz.equals(Boolean.TYPE); case BYTE: return clazz.equals(Byte.TYPE); case CHAR: return clazz.equals(Character.TYPE); case DOUBLE: return clazz.equals(Double.TYPE); case FLOAT: return clazz.equals(Float.TYPE); case INT: return clazz.equals(Integer.TYPE); case LONG: return clazz.equals(Long.TYPE); case SHORT: return clazz.equals(Short.TYPE); default: throw new IllegalArgumentException(type + " cannot be represented as a Class<?>."); } }
Example 2
Source File: CtTypes.java From doma with Apache License 2.0 | 6 votes |
@Override public Class<?> visitPrimitive(PrimitiveType t, Void p) { switch (t.getKind()) { case BOOLEAN: return PrimitiveBooleanWrapper.class; case BYTE: return PrimitiveByteWrapper.class; case SHORT: return PrimitiveShortWrapper.class; case INT: return PrimitiveIntWrapper.class; case LONG: return PrimitiveLongWrapper.class; case FLOAT: return PrimitiveFloatWrapper.class; case DOUBLE: return PrimitiveDoubleWrapper.class; case CHAR: return null; default: return assertUnreachable(); } }
Example 3
Source File: Rewriter.java From j2objc with Apache License 2.0 | 5 votes |
private TypeKind getPrimitiveKind(TypeMirror t) { if (t == null) { return null; } if (t.getKind().isPrimitive()) { return t.getKind(); } PrimitiveType p = typeUtil.unboxedType(t); return p != null ? p.getKind() : null; }
Example 4
Source File: Util.java From revapi with Apache License 2.0 | 5 votes |
@Override protected Void doVisitPrimitive(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; }
Example 5
Source File: Util.java From revapi with Apache License 2.0 | 5 votes |
@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; }
Example 6
Source File: FunctionalType.java From FreeBuilder with Apache License 2.0 | 5 votes |
/** * Returns one of {@link IntUnaryOperator}, {@link LongUnaryOperator} or * {@link DoubleUnaryOperator}, depending on {@code type}. * * @throws IllegalArgumentException if {@code type} is not one of int, long or double */ public static FunctionalType primitiveUnaryOperator(PrimitiveType type) { switch (type.getKind()) { case INT: return new FunctionalType( Type.from(IntUnaryOperator.class), "applyAsInt", ImmutableList.of(type), type); case LONG: return new FunctionalType( Type.from(LongUnaryOperator.class), "applyAsLong", ImmutableList.of(type), type); case DOUBLE: return new FunctionalType( Type.from(DoubleUnaryOperator.class), "applyAsDouble", ImmutableList.of(type), type); default: throw new IllegalArgumentException("No primitive unary operator exists for " + type); } }
Example 7
Source File: ELTypeUtilities.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean isSameType(CompilationContext info, final Node paramNode, final VariableElement param) { TypeKind paramKind = param.asType().getKind(); if (!paramKind.isPrimitive()) { // try unboxing try { PrimitiveType unboxedType = info.info().getTypes().unboxedType(param.asType()); paramKind = unboxedType.getKind(); } catch (IllegalArgumentException iae) { // not unboxable (isn't there a way to check this before trying to unbox??) } } if (TYPES.containsKey(paramNode.getClass())) { return TYPES.get(paramNode.getClass()).contains(paramKind); } if (paramNode instanceof AstString) { CharSequence typeName = info.info().getTypeUtilities().getTypeName(param.asType(), TypeNameOptions.PRINT_FQN); if (String.class.getName().contentEquals(typeName)) { return true; } if (paramKind == TypeKind.DECLARED) { return isSubtypeOf(info, param.asType(), "java.lang.Enum"); // NOI18N } return false; } // the ast param is an object whose real type we don't know // would need to further type inference for more exact matching return true; }
Example 8
Source File: TypeMonikerFactory.java From hottub with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 9
Source File: TypeMonikerFactory.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 10
Source File: TypeMonikerFactory.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 11
Source File: TypeMonikerFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 12
Source File: TypeMonikerFactory.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 13
Source File: TypeMonikerFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 14
Source File: TypeMonikerFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }
Example 15
Source File: Marshallers.java From bazel with Apache License 2.0 | 4 votes |
@Override public boolean matches(PrimitiveType type) { return type.getKind() == TypeKind.INT; }
Example 16
Source File: Marshallers.java From bazel with Apache License 2.0 | 4 votes |
@Override public boolean matches(PrimitiveType type) { return type.getKind() == TypeKind.LONG; }
Example 17
Source File: Marshallers.java From bazel with Apache License 2.0 | 4 votes |
@Override public boolean matches(PrimitiveType type) { return type.getKind() == TypeKind.BYTE; }
Example 18
Source File: Marshallers.java From bazel with Apache License 2.0 | 4 votes |
@Override public boolean matches(PrimitiveType type) { return type.getKind() == TypeKind.BOOLEAN; }
Example 19
Source File: Marshallers.java From bazel with Apache License 2.0 | 4 votes |
@Override public boolean matches(PrimitiveType type) { return type.getKind() == TypeKind.DOUBLE; }
Example 20
Source File: TypeMonikerFactory.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public PrimitiveTypeMoniker(PrimitiveType type) { kind = type.getKind(); }