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;
}
Aggregations