public MutableTypeMirror toMutableType(Type javaType) { if (javaType instanceof Class) { return toMutableType((Class<?>)javaType); } if (javaType instanceof MutableTypeMirror) { return (MutableTypeMirror)javaType; } return null; }
public Type applyTypeParameters(Type type, DeclaredType declaredType) { if (declaredType.getTypeArguments() != null && declaredType.getTypeArguments().size() > 0) { MutableTypeVariable[] variables = new MutableTypeVariable[declaredType.getTypeArguments().size()]; int i = 0; for (TypeMirror typeArgumentMirror: declaredType.getTypeArguments()) { variables[i++] = processingEnv.getTypeUtils().getTypeVariable(null, processingEnv.getTypeUtils().toMutableType(typeArgumentMirror)); } return processingEnv.getTypeUtils().getDeclaredType((MutableDeclaredType)processingEnv.getTypeUtils().toMutableType(type), variables); } return type; }
protected TypeElement fromMutable(MutableDeclaredType mutableDeclaredType) { return (TypeElement) ((DeclaredType) processingEnv.getTypeUtils().fromMutableType(mutableDeclaredType)).asElement(); }
public MutableDeclaredType getDeclaredType(MutableDeclaredType type, MutableDeclaredType... typeArgs) { MutableTypeVariable[] typeVariables = new MutableTypeVariable[typeArgs.length]; for (int i = 0; i < typeArgs.length; i++) { typeVariables[i] = getTypeVariable(null, typeArgs[i]); } return getDeclaredType(type, typeVariables); }
public MutableTypeValue getAnnotationTypeValue(Object value) { if (value.getClass().isArray()) { return getAnnotationArrayValue(getArrayType(toMutableType(value.getClass().getComponentType())), (Object[])value); } return getTypeValue(value); }
public MutableTypeValue getTypeValue(Object value) { if (value.getClass().isArray()) { return getArrayValue(getArrayType(toMutableType(value.getClass().getComponentType())), (Object[])value); } if (value.getClass().isEnum()) { return getEnumValue(value); } return getTypeValue(toMutableType(value.getClass()), value); }
public ThemeUiBinderType(String name, MutableDeclaredType type, MutableProcessingEnvironment processingEnv) { this.mutableTypes = processingEnv.getTypeUtils(); this.prefixName = name; setKind(MutableTypeKind.INTERFACE); setSuperClass(mutableTypes.toMutableType(UiBinder.class).setTypeVariables(mutableTypes.getTypeVariable(null, mutableTypes.toMutableType(Element.class)), mutableTypes.getTypeVariable(null, type))); setModifier(); }
@Override protected MutableDeclaredType getDelegate() { return processingEnv.getTypeUtils().getDeclaredType( processingEnv.getTypeUtils().toMutableType(BeanWrapper.class), new MutableDeclaredType[] { bean }); } }
if (processingEnv.getTypeUtils().implementsType(typeParameterElement, mutableDataInterface)) { typeParameters[i++] = processingEnv .getTypeUtils() .getTypeVariable(null, mutableDataInterface); } else { typeParameters[i++] = typeParameterElement; List<MutableWildcardType> wildcardType = new ArrayList<MutableWildcardType>(); for (int i = 0; i < mutableDataInterface.getTypeVariables().size(); i++) { wildcardType.add(processingEnv.getTypeUtils().getWildcardType((MutableTypeMirror)null, null)); setSuperClass(processingEnv.getTypeUtils().getDeclaredType((MutableDeclaredType) processingEnv.getTypeUtils().toMutableType(AbstractHibernateCRUD.class), new MutableDeclaredType[] { mutableDataInterface })); } else { setSuperClass(processingEnv.getTypeUtils().getDeclaredType( (MutableDeclaredType) processingEnv.getTypeUtils() .toMutableType(AbstractHibernateCRUD.class), new MutableDeclaredType[] { mutableDomainType }));
return addToCache(new MutableArray(toMutableType(((ArrayType)typeMirror).getComponentType())), typeMirror); case DECLARED: case BOOLEAN: case SHORT: case VOID: return convertToMutableType(typeMirror); case WILDCARD: WildcardType wildcardType = (WildcardType)typeMirror; return getWildcardType(toMutableType(wildcardType.getExtendsBound()), toMutableType(wildcardType.getSuperBound())); List<? extends TypeMirror> upperBounds = directSupertypes(typeVariable.getUpperBound()); List<? extends TypeMirror> lowerBounds = directSupertypes(typeVariable.getLowerBound()); return getTypeVariable(name, toMutableTypes(upperBounds), toMutableTypes(lowerBounds)); case NULL: case NONE:
public MutableTypeMirror toParamType(TypeMirror type) { switch (type.getKind()) { case TYPEVAR: return processingEnv.getTypeUtils().getTypeVariable(((TypeVariable)type).asElement().getSimpleName().toString()); case ARRAY: return processingEnv.getTypeUtils().getArrayType(toParamType(((ArrayType)type).getComponentType())); case DECLARED: MutableDeclaredType mutableType = (MutableDeclaredType) processingEnv.getTypeUtils().toMutableType(type); return mutableType.stripTypeParametersTypes(); default: return processingEnv.getTypeUtils().toMutableType(type); } }
protected MutableDeclaredType toParametrizedMutableDeclaredType(MutableDeclaredType baseType, MutableDeclaredType... typeVariables) { for(MutableDeclaredType typeVariable : typeVariables) { baseType.addTypeVariable(processingEnv.getTypeUtils().getTypeVariable(null, typeVariable)); } return baseType; }
return processingEnv.getTypeUtils().toMutableType(((Class) value)).toString(serializer, typed) + ".class"; if (unboxType(processingEnv.getTypeUtils().fromMutableType(type)).getKind().isPrimitive()) { return value.toString(); result += processingEnv.getTypeUtils().getTypeValue(method.invoke(value)).toString(serializer, typed); i++; } catch (Exception e) {}
protected MutableReferenceType getTransactionModelReference(TransactionPropagationAccessor transactionPropagationAccessor) { MutableTypes typeUtils = processingEnv.getTypeUtils(); MutableDeclaredType transactionPropagationModel = typeUtils.toMutableType(TransactionPropagationModel.class); return processingEnv.getTypeUtils().getReference(typeUtils.getArrayValue(typeUtils.getArrayType(transactionPropagationModel), (Object[])transactionPropagationAccessor.getPropagations()), HibernateParameterResolverDelegate.TRANSACTION_PROPAGATION_NAME); }
private String getParameterName(VariableElement parameter, ParameterElement... additionalParameters) { MutableTypes typeUtils = processingEnv.getTypeUtils(); for (ParameterElement additionalParameter: additionalParameters) { if (isPropagated(additionalParameter) && typeUtils.isSameType(typeUtils.toMutableType(parameter.asType()), additionalParameter.getType())) { return additionalParameter.getName(); } } return null; }
public MutableDeclaredType applyVariableTypeParameters(MutableDeclaredType type, DeclaredType declaredType) { if (declaredType.getTypeArguments() != null && declaredType.getTypeArguments().size() > 0) { MutableTypeVariable[] variables = new MutableTypeVariable[declaredType.getTypeArguments().size()]; int i = 0; for (TypeMirror typeParameterElement: declaredType.getTypeArguments()) { if (typeParameterElement.getKind().equals(TypeKind.TYPEVAR)) { variables[i] = processingEnv.getTypeUtils().getTypeVariable(typeParameterElement.toString()); } else { variables[i] = processingEnv.getTypeUtils().getWildcardType((MutableTypeMirror)null, null); } i++; } return processingEnv.getTypeUtils().getDeclaredType(type, variables); } return type; }
private boolean isAbstract(TypeElement dataElement) { DomainDataInterfaceType domainDataInterfaceType = new DomainDataInterfaceType((MutableDeclaredType) processingEnv.getTypeUtils().toMutableType(dataElement.asType()), processingEnv); for (MutableTypeMirror interfaceType: domainDataInterfaceType.getInterfaces()) { if (!(interfaceType instanceof AbstractDataType)) { if (hasAbstractMethod( (TypeElement)((DeclaredType) processingEnv.getTypeUtils().fromMutableType(interfaceType)).asElement())) { return true; } } } return false; }
protected MutableTypeMirror castToDomainDataInterface(MutableTypeMirror mutableType) { TypeMirror type = processingEnv.getTypeUtils().fromMutableType(mutableType); arguments.add(processingEnv.getTypeUtils().getTypeVariable(typeVariable.asElement().getSimpleName().toString(), castToDomainDataInterface(typeVariable.getUpperBound()), castToDomainDataInterface(typeVariable.getLowerBound()))); break; case WILDCARD: arguments.add(processingEnv.getTypeUtils().getWildcardType(castToDomainDataInterface(wildcardType.getExtendsBound()), castToDomainDataInterface(wildcardType.getSuperBound()))); break; case DECLARED: arguments.add(processingEnv.getTypeUtils().getTypeVariable(null, castToDomainDataInterface(declaredType))); break; default:
protected void addImplementedInterface(Class<?> iface) { MutableTypes types = new MutableTypes(null, null, null); addImplementedInterface(types.toMutableType(iface)); }
protected ParameterElement getTransactionPropagationModel() { return new ParameterElement(processingEnv.getTypeUtils().getArrayType(processingEnv.getTypeUtils().toMutableType(TransactionPropagationModel.class)), TRANSACTION_PROPAGATION_NAME, new ParameterUsageProvider() { @Override public MutableType getUsage(ParameterUsageContext context) { TransactionPropagationAccessor transactionPropagationAccessor = new TransactionPropagationAccessor(context.getMethod(), processingEnv); return getTransactionModelReference(transactionPropagationAccessor); } }, getTransactionPropagationModelParameterPropagation()); }