protected boolean _isLeaf(ModalPropertyValue ml) {
    if (ml.getInModes().isEmpty()) {
      if (ml.getOwnedValue() instanceof RangeValue) {
        return false;
      }

      if (ml.getOwnedValue() instanceof ListValue) {
        return false;
      }

      if (ml.getOwnedValue() instanceof RecordValue) {
        return false;
      }

      return true;
    }
    return false;
  }
Beispiel #2
0
  /**
   * get a property association from the properties section of the containing classifier if the
   * context. This method has been designed to work with end points of connections, i.e., consisting
   * of a target and a context. The context must be a NamedElement in its containing classifier,
   * i.e., a feature, feature group, subcomponent. The property holder is assumed to be contained in
   * the context object, e.g., a feature in afeature group or a data subcomponent in a port, or
   * feature in a subcomponent. The association must match the property definition. if the context
   * is null then the containing classifier of the target is used and the path must be one or no
   * path. The applies to clause of the property association must be of size 2 if the context is set
   * and point to the context and then the property holder. The property value of the property
   * association is assumed not to be modal.
   *
   * @param context NamedElement whose containing classifier's properties section is searched for
   *     the desired property
   * @param target NamedElement the model element to which the property is applied to via the
   *     applies to clause
   * @param pd Property the property definition
   * @return
   */
  public static PropertyExpression getContainedSimplePropertyValue(
      final NamedElement context, final NamedElement target, final Property pd) {
    if (context == null) return target.getNonModalPropertyValue(pd);
    Classifier cl = AadlUtil.getContainingClassifier(context);
    EList<PropertyAssociation> props = cl.getAllPropertyAssociations();
    for (PropertyAssociation propertyAssociation : props) {
      if (propertyAssociation.getProperty().equals(pd)) {
        // we found a property with the corect type
        // now we need to check whether the applies to points to the holder
        EList<ContainedNamedElement> appliestos = propertyAssociation.getAppliesTos();
        for (ContainedNamedElement containedNamedElement : appliestos) {
          EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
          if (cpes.size() == 2) {
            NamedElement pathcxt = cpes.get(0).getNamedElement();
            NamedElement pathelement = cpes.get(1).getNamedElement();
            if (context.equals(pathcxt) && target.equals(pathelement)) {
              EList<ModalPropertyValue> vallist = propertyAssociation.getOwnedValues();
              if (!vallist.isEmpty()) {
                ModalPropertyValue elem = vallist.get(0);
                PropertyExpression res = elem.getOwnedValue();
                if (res instanceof NamedValue) {
                  AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
                  if (nv instanceof Property) {
                    res = target.getNonModalPropertyValue((Property) nv);
                  } else if (nv instanceof PropertyConstant) {
                    res = ((PropertyConstant) nv).getConstantValue();
                  }
                }

                return res;
              }
            }
          }
        }
      }
    }
    return null;
  }