Search in sources :

Example 61 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class CommunicationProperties method getOutputTime.

public static Optional<List<IoTimeSpec>> getOutputTime(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getOutputTime_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return new IoTimeSpec(resolved1, lookupContext, mode);
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 62 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class DeploymentProperties method getAllowedConnectionBinding.

public static Optional<List<InstanceObject>> getAllowedConnectionBinding(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getAllowedConnectionBinding_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return ((InstanceReferenceValue) resolved1).getReferencedInstanceObject();
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Property(org.osate.aadl2.Property)

Example 63 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class DeploymentProperties method getActualConnectionBinding.

public static Optional<List<InstanceObject>> getActualConnectionBinding(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getActualConnectionBinding_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return ((InstanceReferenceValue) resolved1).getReferencedInstanceObject();
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Property(org.osate.aadl2.Property)

Example 64 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class DeploymentProperties method getAllowedConnectionType.

public static Optional<List<AllowedConnectionType>> getAllowedConnectionType(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getAllowedConnectionType_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((ListValue) resolved).getOwnedListElements().stream().map(element1 -> {
            PropertyExpression resolved1 = CodeGenUtil.resolveNamedValue(element1, lookupContext, mode);
            return AllowedConnectionType.valueOf(resolved1);
        }).collect(Collectors.toList()));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 65 with ListValue

use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.

the class PropertyUtils method getSubcomponentList.

/**
 * May return an empty list.
 *
 * @param object
 * @param propertyName
 * @return
 */
public static List<Subcomponent> getSubcomponentList(ProcessorSubcomponent object, String propertyName) {
    List<Subcomponent> res = new ArrayList<Subcomponent>();
    PropertyAssociation pa = findPropertyAssociation(propertyName, object);
    if (pa != null) {
        Property p = pa.getProperty();
        if (p.getName().equalsIgnoreCase(propertyName)) {
            List<ModalPropertyValue> values = pa.getOwnedValues();
            if (values.size() == 1) {
                ModalPropertyValue v = values.get(0);
                PropertyExpression expr = v.getOwnedValue();
                if (expr instanceof ListValue) {
                    ListValue lv = (ListValue) expr;
                    for (PropertyExpression pe : lv.getOwnedListElements()) {
                        if (pe instanceof ReferenceValue) {
                            ReferenceValue c = ((ReferenceValue) pe);
                            ContainmentPathElement cpe = c.getContainmentPathElements().get(c.getContainmentPathElements().size() - 1);
                            res.add((Subcomponent) cpe.getNamedElement());
                        }
                    }
                }
            }
        }
    }
    // try on a refined NamedElement
    if (object instanceof RefinableElement) {
        RefinableElement re = object;
        if (re.getRefinedElement() != null) {
            List<Subcomponent> l = getSubcomponentList((ProcessorSubcomponent) re.getRefinedElement(), propertyName);
            if (!l.isEmpty()) {
                res.addAll(l);
            }
        }
    }
    return res;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) ReferenceValue(org.osate.aadl2.ReferenceValue) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ListValue(org.osate.aadl2.ListValue) ArrayList(java.util.ArrayList) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) PropertyExpression(org.osate.aadl2.PropertyExpression) RefinableElement(org.osate.aadl2.RefinableElement) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property)

Aggregations

ListValue (org.osate.aadl2.ListValue)101 PropertyExpression (org.osate.aadl2.PropertyExpression)85 Property (org.osate.aadl2.Property)64 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)51 ClassifierValue (org.osate.aadl2.ClassifierValue)29 StringLiteral (org.osate.aadl2.StringLiteral)24 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)22 PropertyAssociation (org.osate.aadl2.PropertyAssociation)21 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)21 IntegerLiteral (org.osate.aadl2.IntegerLiteral)19 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)19 RecordValue (org.osate.aadl2.RecordValue)19 ReferenceValue (org.osate.aadl2.ReferenceValue)16 NamedValue (org.osate.aadl2.NamedValue)15 Classifier (org.osate.aadl2.Classifier)14 RangeValue (org.osate.aadl2.RangeValue)13 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)12 ArrayList (java.util.ArrayList)11 BooleanLiteral (org.osate.aadl2.BooleanLiteral)11 PropertyConstant (org.osate.aadl2.PropertyConstant)11