Search in sources :

Example 11 with FeatureGroupPrototypeBinding

use of org.osate.aadl2.FeatureGroupPrototypeBinding in project osate2 by osate.

the class ResolvePrototypeUtil method resolveFeatureGroupPrototype.

/**
 * Find the binding for a given feature group prototype.
 *
 * @param proto the prototype to resolve
 * @param context the context of the feature group in which the prototype is used, e.g., a
 *            ComponentType, FeatureGroupType, ContainmentPathElement
 * @return The feature group prototype actual the prototype is bound to.
 */
public static FeatureGroupType resolveFeatureGroupPrototype(FeatureGroupPrototype proto, Element context) {
    FeatureGroupPrototypeBinding fgpb = (FeatureGroupPrototypeBinding) resolvePrototype(proto, context);
    if (fgpb == null) {
        // look for constraining classifier
        FeatureGroupPrototype refinedPrototype = proto;
        while (refinedPrototype.getConstrainingFeatureGroupType() != null && refinedPrototype.getRefined() instanceof FeatureGroupPrototype) {
            refinedPrototype = (FeatureGroupPrototype) refinedPrototype.getRefined();
        }
        if (refinedPrototype.getConstrainingFeatureGroupType() != null) {
            return refinedPrototype.getConstrainingFeatureGroupType();
        } else {
            return null;
        }
    }
    FeatureGroupPrototypeActual actual = fgpb.getActual();
    if (actual.getFeatureType() instanceof FeatureGroupType) {
        return (FeatureGroupType) actual.getFeatureType();
    } else {
        if (actual.getFeatureType() instanceof Prototype && context instanceof ContainmentPathElement) {
            // resolve recursively if we are in a containment path
            return resolveFeatureGroupPrototype((FeatureGroupPrototype) actual.getFeatureType(), getPrevious((ContainmentPathElement) context));
        }
    }
    return null;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Prototype(org.osate.aadl2.Prototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual)

Aggregations

FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)10 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)8 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)8 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)6 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)6 AccessSpecification (org.osate.aadl2.AccessSpecification)5 PortSpecification (org.osate.aadl2.PortSpecification)5 PrototypeBinding (org.osate.aadl2.PrototypeBinding)5 AadlString (org.osate.aadl2.AadlString)4 ComponentPrototype (org.osate.aadl2.ComponentPrototype)4 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)4 FeatureGroupType (org.osate.aadl2.FeatureGroupType)4 FeaturePrototype (org.osate.aadl2.FeaturePrototype)4 FeaturePrototypeReference (org.osate.aadl2.FeaturePrototypeReference)4 AbstractFeature (org.osate.aadl2.AbstractFeature)3 ClassifierValue (org.osate.aadl2.ClassifierValue)3 ComponentClassifier (org.osate.aadl2.ComponentClassifier)3 DataClassifier (org.osate.aadl2.DataClassifier)3 DataPrototype (org.osate.aadl2.DataPrototype)3 DataSubcomponent (org.osate.aadl2.DataSubcomponent)3