use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.
the class ValidateConnectionsSwitch method classifiersFoundInSupportedTypeConversionsProperty.
// XXX How can I avoid duplicating this method for the instance and the declarative models?
private boolean classifiersFoundInSupportedTypeConversionsProperty(ConnectionInstance connection, Classifier source, Classifier destination) {
PropertyConstant conversionsPropertyConstant = GetProperties.lookupPropertyConstant(connection, AadlProject.SUPPORTED_TYPE_CONVERSIONS);
if (conversionsPropertyConstant == null) {
return false;
}
PropertyExpression constantValue = conversionsPropertyConstant.getConstantValue();
if (!(constantValue instanceof ListValue)) {
return false;
}
for (PropertyExpression classifierPair : ((ListValue) constantValue).getOwnedListElements()) {
if (classifierPair instanceof ListValue) {
EList<PropertyExpression> innerListElements = ((ListValue) classifierPair).getOwnedListElements();
if (innerListElements.size() == 2 && innerListElements.get(0) instanceof ClassifierValue && innerListElements.get(1) instanceof ClassifierValue) {
Classifier firstPairElement = ((ClassifierValue) innerListElements.get(0)).getClassifier();
Classifier secondPairElement = ((ClassifierValue) innerListElements.get(1)).getClassifier();
if (firstPairElement == source && secondPairElement == destination) {
return true;
}
}
}
}
return false;
}
use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.
the class AbstractInstanceSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Aadl2Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Aadl2Package.ARRAY_RANGE:
sequence_ArrayRange(context, (ArrayRange) semanticObject);
return;
case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
return;
case Aadl2Package.BOOLEAN_LITERAL:
sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
return;
case Aadl2Package.CLASSIFIER_VALUE:
sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
return;
case Aadl2Package.COMPUTED_VALUE:
sequence_ComputedTerm(context, (ComputedValue) semanticObject);
return;
case Aadl2Package.CONTAINED_NAMED_ELEMENT:
sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
return;
case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
return;
case Aadl2Package.INTEGER_LITERAL:
sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
return;
case Aadl2Package.LIST_VALUE:
sequence_ListTerm(context, (ListValue) semanticObject);
return;
case Aadl2Package.MODAL_PROPERTY_VALUE:
if (rule == grammarAccess.getModalPropertyValueRule()) {
sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyValueRule()) {
sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else
break;
case Aadl2Package.NAMED_VALUE:
if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
sequence_ConstantValue(context, (NamedValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
return;
} else
break;
case Aadl2Package.OPERATION:
sequence_SignedConstant(context, (Operation) semanticObject);
return;
case Aadl2Package.PROPERTY_ASSOCIATION:
if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyAssociationRule()) {
sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else
break;
case Aadl2Package.RANGE_VALUE:
sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
return;
case Aadl2Package.REAL_LITERAL:
sequence_RealTerm(context, (RealLiteral) semanticObject);
return;
case Aadl2Package.RECORD_VALUE:
if (rule == grammarAccess.getOldRecordTermRule()) {
sequence_OldRecordTerm(context, (RecordValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
sequence_RecordTerm(context, (RecordValue) semanticObject);
return;
} else
break;
case Aadl2Package.REFERENCE_VALUE:
sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
return;
case Aadl2Package.STRING_LITERAL:
sequence_StringTerm(context, (StringLiteral) semanticObject);
return;
}
else if (epackage == InstancePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case InstancePackage.COMPONENT_INSTANCE:
sequence_ComponentInstance(context, (ComponentInstance) semanticObject);
return;
case InstancePackage.CONNECTION_INSTANCE:
sequence_ConnectionInstance(context, (ConnectionInstance) semanticObject);
return;
case InstancePackage.CONNECTION_REFERENCE:
sequence_ConnectionReference(context, (ConnectionReference) semanticObject);
return;
case InstancePackage.END_TO_END_FLOW_INSTANCE:
sequence_EndToEndFlowInstance(context, (EndToEndFlowInstance) semanticObject);
return;
case InstancePackage.FEATURE_INSTANCE:
sequence_FeatureInstance(context, (FeatureInstance) semanticObject);
return;
case InstancePackage.FLOW_SPECIFICATION_INSTANCE:
sequence_FlowSpecificationInstance(context, (FlowSpecificationInstance) semanticObject);
return;
case InstancePackage.INSTANCE_REFERENCE_VALUE:
sequence_InstanceReferenceValue(context, (InstanceReferenceValue) semanticObject);
return;
case InstancePackage.MODE_INSTANCE:
sequence_ModeInstance(context, (ModeInstance) semanticObject);
return;
case InstancePackage.MODE_TRANSITION_INSTANCE:
sequence_ModeTransitionInstance(context, (ModeTransitionInstance) semanticObject);
return;
case InstancePackage.PROPERTY_ASSOCIATION_INSTANCE:
sequence_PropertyAssociationInstance(context, (PropertyAssociationInstance) semanticObject);
return;
case InstancePackage.SYSTEM_INSTANCE:
sequence_SystemInstance(context, (SystemInstance) semanticObject);
return;
case InstancePackage.SYSTEM_OPERATION_MODE:
sequence_SystemOperationMode(context, (SystemOperationMode) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.
the class NamedElementImpl method setPropertyValue.
public final PropertyAssociation setPropertyValue(final Property pd, final List<? extends PropertyExpression> pes) {
checkPropertyAssociation(pd, pes);
PropertyAssociation pa = Aadl2Factory.eINSTANCE.createPropertyAssociation();
pa.setProperty(pd);
ModalPropertyValue mpv = pa.createOwnedValue();
ListValue lv = (ListValue) mpv.createOwnedValue(Aadl2Package.eINSTANCE.getListValue());
lv.getOwnedListElements().addAll(pes);
if (this instanceof InstanceObject) {
final SystemInstance si = ((InstanceObject) this).getSystemInstance();
final SystemOperationMode som = si.getCurrentSystemOperationMode();
if (som == null) {
// non-modal instance model
removePropertyAssociations(pd);
} else {
mpv.getInModes().add(som);
removePropertyAssociations(pd, Collections.singletonList(som));
}
} else {
removePropertyAssociations(pd);
}
getOwnedPropertyAssociations().add(pa);
return pa;
}
use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.
the class NamedElementImpl method getPropertyValueList.
/**
* Retrieves a non-modal property value as a list. Use this method if you
* know that the property is defined as a LIST OF. While this method can be used
* on scalar properties, getSimplePropertyValue should be used if you know that it is
* scalar. If the property is scalar, a list of length 1 is returned.
*
* @param property PropertyDefinition
* @return A list of PropertyValues. This does not return null.
*/
public final List<PropertyExpression> getPropertyValueList(final Property property) throws InvalidModelException, IllegalArgumentException, PropertyNotPresentException, PropertyIsModalException, IllegalStateException, PropertyDoesNotApplyToHolderException {
try {
PropertyExpression pe = getNonModalPropertyValue(property);
if (pe instanceof ListValue) {
return ((ListValue) pe).getOwnedListElements();
} else {
List<PropertyExpression> pes = new BasicEList<PropertyExpression>();
pes.add(pe);
return pes;
}
} catch (Exception e) {
return Collections.emptyList();
}
}
use of com.google.api.expr.v1alpha1.ListValue in project osate2 by osate.
the class ListValueImpl method evaluate.
/*
* (non-Javadoc)
*
* @see org.osate.aadl2.impl.PropertyExpressionImpl#evaluate(org.osate.aadl2.properties.EvaluationContext, int)
*/
public EvaluatedProperty evaluate(EvaluationContext ctx, int depth) {
// evaluate each list element
ListValue newVal = Aadl2Factory.eINSTANCE.createListValue();
int i = 0;
for (PropertyExpression elem : getOwnedListElements()) {
i += 1;
EvaluatedProperty elemVal = elem.evaluate(ctx, depth + 1);
if (elemVal.isEmpty()) {
throw new InvalidModelException(this, "Element " + i + " has no value");
}
if (elemVal.size() > 1) {
throw new InvalidModelException(this, "Element " + i + " has multiple values");
}
if (elemVal.first().isModal()) {
throw new InvalidModelException(this, "Element " + i + ": value is modal");
}
PropertyExpression exp = elemVal.first().getValue();
newVal.getOwnedListElements().add(exp);
}
return new EvaluatedProperty(newVal);
}
Aggregations