"final $T res = ", singleParameterType.isBoxedPrimitive() ? singleParameterType.unbox() : singleParameterType) .addStatement(statement, formatObjects)
.endControlFlow() .beginControlFlow("for (int i = 0; i < $L.size(); i++)", parameterName) .add("final $T res = ", resType.isBoxedPrimitive() ? resType.unbox() : resType) .addStatement(statement, formatObjects) .addStatement("this.$L.$L.add(res)", componentMemberInstanceName, propName)
public static TypeName unbox(TypeName typeName) { try { return typeName.unbox(); } catch (Exception e) { return typeName; } }
public static TypeName unbox(TypeName typeName) { try { return typeName.unbox(); } catch (UnsupportedOperationException ignore) { return typeName; } }
private TypeName unboxTypeName(TypeName tn) { TypeName n = tn; try { n = tn.unbox(); } catch (UnsupportedOperationException ex) { } return n; }
@Nonnull public static TypeName unbox(@Nonnull TypeName source) { try { return source.unbox(); } catch (UnsupportedOperationException e) { return source; } } }
@Nonnull @CheckReturnValue static TypeName unbox(@Nonnull TypeName typeName) { try { return typeName.unbox(); } catch (Exception e) { return typeName; } }
public static TypeName asUnboxType(TypeName type) { if (type.isBoxedPrimitive()) { return type.unbox(); } else { return type; } }
private static TypeName detectConvertedTypeNameByClass(Class clazz) { Type converted = getConverterGenericsTypesByClass(clazz)[1]; TypeName typeName = TypeName.get(converted); try { typeName = typeName.unbox(); } catch (UnsupportedOperationException ignore) {} return typeName; }
private static TypeName detectConvertedTypeByTypeElement(TypeElement element) { TypeMirror typeMirror = getConverterGenericsTypesByTypeElement(element).get(1); TypeName typeName = TypeName.get(typeMirror); try { typeName = typeName.unbox(); } catch (UnsupportedOperationException ignore) {} return typeName; }
private boolean isUnboxPrimitive(TypeName tn) { TypeName n = tn; try { n = tn.unbox(); } catch (UnsupportedOperationException ex) { } return n.isPrimitive(); }
private TypeName unbox(TypeName typeName) { if (typeName.isBoxedPrimitive()) { return typeName.unbox(); } return typeName; }
/** * Returns the parameter type for {@code dependency}. If the raw type is not accessible, returns * {@link Object}. */ private static TypeName accessibleType(DependencyRequest dependency) { TypeName typeName = requestTypeName(dependency.kind(), accessibleType(dependency.key().type())); return dependency .requestElement() .map(element -> element.asType().getKind().isPrimitive()) .orElse(false) ? typeName.unbox() : typeName; }
/** * @param property the property to generate the parameter * @param useLowercaseBooleans {@link FactoryMethod#useLowercaseBooleans()} * @param copyNullable if true, an existing {@link Nullable} annotation on the model will be copied to the parameter * @return */ protected ParameterSpec createParameter(final PropertyGenModel property, final boolean useLowercaseBooleans, final boolean copyNullable) { TypeName type = property.getType(); if (useLowercaseBooleans && type.isBoxedPrimitive() && type.unbox().equals(TypeName.BOOLEAN)) { type = TypeName.BOOLEAN; } return createParameter(property, type, copyNullable); }
/** * @param property the property to generate the parameter * @param useLowercaseBooleans {@link FactoryMethod#useLowercaseBooleans()} * @param copyNullable if true, an existing {@link Nullable} annotation on the model will be copied to the parameter * @return */ protected ParameterSpec createParameter(final PropertyGenModel property, final boolean useLowercaseBooleans, final boolean copyNullable) { TypeName type = property.getType(); if (useLowercaseBooleans && type.isBoxedPrimitive() && type.unbox().equals(TypeName.BOOLEAN)) { type = TypeName.BOOLEAN; } return createParameter(property, type, copyNullable); }
TypeName unboxed = target.unbox(); if (fieldTypes.containsKey(unboxed)) { return fieldTypes.get(unboxed);
/** * Check type adapter. * * @param entity the entity * @param propertyType the property type * @param typeAdapter the type adapter * @param annotation the annotation */ protected void checkTypeAdapter(@SuppressWarnings("rawtypes") ModelEntity entity, TypeMirror propertyType, TypeAdapter typeAdapter, ModelAnnotation annotation) { TypeName sourceType = TypeUtility.typeName(TypeAdapterHelper.detectSourceType(entity.getElement(), typeAdapter.adapterClazz)); TypeName uboxSourceType=sourceType; if (TypeUtility.isTypeWrappedPrimitive(sourceType)) { uboxSourceType=sourceType.unbox(); } boolean expr=uboxSourceType.toString().equals(propertyType.toString()) || sourceType.toString().equals(propertyType.toString()); AssertKripton.fail(!expr, "In class '%s', property '%s' uses @%s that manages type '%s' instead of '%s'", entity.getElement().asType(), getName(), annotation.getSimpleName(), element.asType().toString(), TypeAdapterHelper.detectSourceType(entity.getElement(), typeAdapter.adapterClazz), getPropertyType().getTypeName()); }
uboxSourceType=sourceType.unbox();
TypeName unboxType; try { unboxType = type.unbox(); } catch (UnsupportedOperationException e) { unboxType = type;