/** Applies unboxing conversion to {@code mirror}, if it can be unboxed. */ public static Optional<TypeMirror> maybeUnbox(TypeMirror mirror, Types types) { try { return Optional.of(types.unboxedType(mirror)); } catch (IllegalArgumentException e) { return Optional.empty(); } }
@Override public PrimitiveType unboxedType(TypeMirror arg0) { return realImpl.unboxedType(arg0); } }
@Override public PrimitiveType unboxedType(TypeMirror arg0) { return realImpl.unboxedType(arg0); } }
@Override public PrimitiveType unboxedType(TypeMirror t) { return this.types.unboxedType(t); }
public static PrimitiveType unboxedType(TypeMirror t) { return types.unboxedType(t); }
@Override public PrimitiveType unboxedType(TypeMirror t) { return types.unboxedType(t); }
@Override public PrimitiveType unboxedType(TypeMirror t) { return delegate.unboxedType( t ); }
public PrimitiveType unboxedType(TypeMirror t) { return typeUtils.unboxedType(t); }
public PrimitiveType unboxedType(TypeMirror t) { return env.getTypeUtils().unboxedType(t); }
public PrimitiveType unboxedType(TypeMirror t) { return env.getTypeUtils().unboxedType(t); }
/** Applies unboxing conversion to {@code mirror}, if it can be unboxed. */ public static Optional<TypeMirror> maybeUnbox(TypeMirror mirror, Types types) { try { return Optional.of(types.unboxedType(mirror)); } catch (IllegalArgumentException e) { return Optional.empty(); } }
private boolean isBoxed(DeclaredType type) { try { PrimitiveType primitiveType = utils.getTypes().unboxedType(type); return primitiveType != null; } catch (IllegalArgumentException e) { return false; } }
public static TypeMirror get(ProcessingEnvironment processingEnvironment, Class<?> cls) { if (cls.isPrimitive()) { if(cls.equals(void.class)) { return processingEnvironment.getTypeUtils().getNoType(TypeKind.VOID); } final Class<?> boxedClass = PRIMITIVES_TO_WRAPPERS.get(cls); final TypeElement boxedElement = processingEnvironment.getElementUtils().getTypeElement(boxedClass.getName()); return processingEnvironment.getTypeUtils().unboxedType(boxedElement.asType()); } return processingEnvironment.getElementUtils().getTypeElement(cls.getName()).asType(); } }
public PrimitiveType unboxedType(TypeMirror t) { while (t instanceof DecoratedTypeMirror) { t = ((DecoratedTypeMirror) t).getDelegate(); } return TypeMirrorDecorator.decorate(delegate.unboxedType(t), this.env); } }
public PrimitiveType unboxedType(TypeMirror t) { while (t instanceof DecoratedTypeMirror) { t = ((DecoratedTypeMirror) t).getDelegate(); } return TypeMirrorDecorator.decorate(delegate.unboxedType(t), this.env); } }
/** * Returns true if the argument type is a numeric primitive or a boxed numeric primitive and * false otherwise. */ protected boolean isNumericOrBoxed(TypeMirror type) { if (TypesUtils.isBoxedPrimitive(type)) { type = types.unboxedType(type); } return TypesUtils.isNumeric(type); }
private static PrimitiveType getUnboxedPrimitive(DeclaredType declaredType, MapperGeneratorContext context) { PrimitiveType res = null; final PackageElement typePackage = context.elements.getPackageOf(declaredType.asElement()); final PackageElement javaLang = context.elements.getPackageElement("java.lang"); if (typePackage.getSimpleName().equals(javaLang.getSimpleName())) { try { res = context.type.unboxedType(declaredType); } catch (IllegalArgumentException ignored) { } } return res; }
@Override public AnnotationClass unbox() { if (!isNullable()) { return this; } try { return new AnnotationClass(getTypeUtils().unboxedType(mTypeMirror)); } catch (IllegalArgumentException e) { // I'm being lazy. This is much easier than checking every type. return this; } }
/** * Perform narrowing conversion and optionally boxing conversion on the input node to make * it match the destination type. * * @param node a node producing a value of numeric primitive type * @param destType the type to narrow the value to (possibly boxed) * @return a Node with the value narrowed and boxed to the destType, which may be the input * node */ protected Node narrowAndBox(Node node, TypeMirror destType) { if (TypesUtils.isBoxedPrimitive(destType)) { return box(narrow(node, types.unboxedType(destType))); } else { return narrow(node, destType); } }
public String getSensibleDefault() { if ( isPrimitive() ) { return getNull(); } else if ( "String".equals( getName() ) ) { return "\"\""; } else { if ( isNative() ) { // must be boxed, since primitive is already checked return typeFactory.getType( typeUtils.unboxedType( typeMirror ) ).getNull(); } } return null; }