/** Add lower type bounds. * @param type the type. */ public void addLowerConstraint(String type) { final JvmLowerBound constraint = this.jvmTypesFactory.createJvmLowerBound(); constraint.setTypeReference(newTypeRef(this.context, type)); getJvmTypeParameter().getConstraints().add(constraint); }
public JvmWildcardTypeReference wildCardSuper(JvmTypeReference clone) { JvmWildcardTypeReference result = factory.createJvmWildcardTypeReference(); JvmLowerBound lowerBound = factory.createJvmLowerBound(); lowerBound.setTypeReference(clone); JvmUpperBound upperBound = factory.createJvmUpperBound(); upperBound.setTypeReference(getTypeForName(Object.class, clone.getType())); result.getConstraints().add(lowerBound); result.getConstraints().add(upperBound); return result; }
@Override public JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper helper) { TypesFactory typesFactory = getTypesFactory(); JvmWildcardTypeReference result = typesFactory.createJvmWildcardTypeReference(); if (upperBounds != null && !upperBounds.isEmpty()) { List<LightweightTypeReference> nonInterfaceTypes = getNonInterfaceTypes(upperBounds); JvmTypeReference upperBound = toJavaCompliantTypeReference(nonInterfaceTypes != null ? nonInterfaceTypes: upperBounds, helper); JvmUpperBound constraint = typesFactory.createJvmUpperBound(); constraint.setTypeReference(upperBound); result.getConstraints().add(constraint); } if (lowerBound != null) { JvmLowerBound constraint = typesFactory.createJvmLowerBound(); constraint.setTypeReference(lowerBound.toJavaCompliantTypeReference()); result.getConstraints().add(constraint); } return result; }
@Override public JvmTypeReference toTypeReference() { TypesFactory typesFactory = getTypesFactory(); JvmWildcardTypeReference result = typesFactory.createJvmWildcardTypeReference(); if (upperBounds != null && !upperBounds.isEmpty()) { for(LightweightTypeReference typeArgument: upperBounds) { JvmUpperBound constraint = typesFactory.createJvmUpperBound(); constraint.setTypeReference(typeArgument.getWrapperTypeIfPrimitive().toTypeReference()); result.getConstraints().add(constraint); } } if (lowerBound != null) { JvmLowerBound constraint = typesFactory.createJvmLowerBound(); constraint.setTypeReference(lowerBound.getWrapperTypeIfPrimitive().toTypeReference()); result.getConstraints().add(constraint); } return result; }
JvmTypeConstraint cst = null; if (constraint instanceof JvmLowerBound) { cst = jvmTypesFactory.createJvmLowerBound(); } else if (constraint instanceof JvmUpperBound) { cst = jvmTypesFactory.createJvmUpperBound();
protected JvmTypeReference createTypeArgument(Type actualTypeArgument) { if (actualTypeArgument instanceof WildcardType) { WildcardType wildcardType = (WildcardType) actualTypeArgument; JvmWildcardTypeReference result = TypesFactory.eINSTANCE.createJvmWildcardTypeReference(); InternalEList<JvmTypeConstraint> constraints = (InternalEList<JvmTypeConstraint>)result.getConstraints(); Type[] upperBounds = wildcardType.getUpperBounds(); if (upperBounds.length != 0) { for (Type boundType : upperBounds) { JvmUpperBound upperBound = TypesFactory.eINSTANCE.createJvmUpperBound(); JvmTypeReference upperBoundType = createTypeReference(boundType); ((JvmTypeConstraintImplCustom) upperBound).internalSetTypeReference(upperBoundType); constraints.addUnique(upperBound); } } Type[] lowerBounds = wildcardType.getLowerBounds(); if (lowerBounds.length != 0) { for (Type boundType : lowerBounds) { JvmLowerBound lowerBound = TypesFactory.eINSTANCE.createJvmLowerBound(); JvmTypeReference lowerBoundType = createTypeReference(boundType); ((JvmTypeConstraintImplCustom) lowerBound).internalSetTypeReference(lowerBoundType); constraints.addUnique(lowerBound); } } return result; } else { JvmTypeReference result = createTypeReference(actualTypeArgument); return result; } }
protected JvmTypeReference createTypeArgument(Type actualTypeArgument) { if (actualTypeArgument instanceof WildcardType) { WildcardType wildcardType = (WildcardType) actualTypeArgument; JvmWildcardTypeReference result = TypesFactory.eINSTANCE.createJvmWildcardTypeReference(); InternalEList<JvmTypeConstraint> constraints = (InternalEList<JvmTypeConstraint>)result.getConstraints(); Type[] upperBounds = wildcardType.getUpperBounds(); if (upperBounds.length != 0) { for (Type boundType : upperBounds) { JvmUpperBound upperBound = TypesFactory.eINSTANCE.createJvmUpperBound(); JvmTypeReference upperBoundType = createTypeReference(boundType); ((JvmTypeConstraintImplCustom) upperBound).internalSetTypeReference(upperBoundType); constraints.addUnique(upperBound); } } Type[] lowerBounds = wildcardType.getLowerBounds(); if (lowerBounds.length != 0) { for (Type boundType : lowerBounds) { JvmLowerBound lowerBound = TypesFactory.eINSTANCE.createJvmLowerBound(); JvmTypeReference lowerBoundType = createTypeReference(boundType); ((JvmTypeConstraintImplCustom) lowerBound).internalSetTypeReference(lowerBoundType); constraints.addUnique(lowerBound); } } return result; } else { JvmTypeReference result = createTypeReference(actualTypeArgument); return result; } }
JvmLowerBound newConstraint = typesFactory.createJvmLowerBound(); newConstraint.setTypeReference(boundUpperBounds.get(0).getTypeReference()); newConstraints.add(newConstraint); } else if (boundUpperBounds.size() > 1) { JvmLowerBound newConstraint = typesFactory.createJvmLowerBound(); JvmMultiTypeReference multiType = typesFactory.createJvmMultiTypeReference(); for(JvmUpperBound boundUpperBound: boundUpperBounds) { JvmLowerBound copiedLowerBound = typesFactory.createJvmLowerBound(); copiedLowerBound.setTypeReference(primitives.asWrapperTypeIfPrimitive(bound)); newConstraints.add(copiedLowerBound);
if (!(paramType instanceof JvmWildcardTypeReference)) { JvmWildcardTypeReference paramWildcard = typesFactory.createJvmWildcardTypeReference(); JvmLowerBound lowerBound = typesFactory.createJvmLowerBound(); JvmTypeReference wrapped = wrapIfNecessary(paramType); if (wrapped == null || wrapped.eContainer() != null) {
JvmLowerBound lowerBound = typesFactory.createJvmLowerBound(); wildCard.getConstraints().add(lowerBound); lowerBound.setTypeReference(reference);
public JvmTypeReference createTypeArgument(BinaryTypeArgumentSignature actualTypeArgument, Map<String, JvmTypeParameter> typeParameters) { if (actualTypeArgument.isWildcard()) { JvmWildcardTypeReference result = TypesFactory.eINSTANCE.createJvmWildcardTypeReference(); InternalEList<JvmTypeConstraint> constraints = (InternalEList<JvmTypeConstraint>) result.getConstraints(); BinaryGenericTypeSignature upperBound = actualTypeArgument.getUpperBound(); if (upperBound != null) { JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound(); JvmTypeReference upperBoundType = createTypeReference(upperBound, typeParameters); ((JvmTypeConstraintImplCustom) jvmUpperBound).internalSetTypeReference(upperBoundType); constraints.addUnique(jvmUpperBound); } else { JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound(); // TODO this might be bogus due to constrained type information on the declarator ((JvmTypeConstraintImplCustom) jvmUpperBound).internalSetTypeReference(createObjectTypeReference()); constraints.addUnique(jvmUpperBound); } BinaryGenericTypeSignature lowerBound = actualTypeArgument.getLowerBound(); if (lowerBound != null) { JvmLowerBound jvmLowerBound = TypesFactory.eINSTANCE.createJvmLowerBound(); JvmTypeReference boundType = createTypeReference(lowerBound, typeParameters); ((JvmTypeConstraintImplCustom) jvmLowerBound).internalSetTypeReference(boundType); constraints.addUnique(jvmLowerBound); } return result; } else { return createTypeReference(actualTypeArgument, typeParameters); } }