use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.
the class PropertyUtils method getInstanceObjectReference.
/**
* Get an InstanceObject from an instance reference value. Throws an
* exception if no property value exists or an error occurs.
*
* @param io The instance object from which to retrieve the property value.
* (We don't use a property holder because we can only get an
* instance reference value as a property value from an instance
* object.)
* @param pd The property to retrieve.
* @return The instance object of the property.
*/
public static InstanceObject getInstanceObjectReference(final InstanceObject io, final Property pd) {
if (io == null) {
return null;
}
try {
final PropertyExpression pv = io.getSimplePropertyValue(pd);
final InstanceObject ref = ((InstanceReferenceValue) pv).getReferencedInstanceObject();
return ref;
} catch (PropertyLookupException e) {
return null;
}
}
use of org.osate.aadl2.instance.InstanceReferenceValue in project osate2 by osate.
the class DefaultBusinessObjectTreeUpdater method createPropertyValues.
private void createPropertyValues(final BusinessObjectNode node, final Property property, final PropertyResult pr, final Object value, final Deque<Integer> indicesStack, final String appliesToDescendantRef, final Multimap<BusinessObjectNode, AgePropertyValue> dstToPropertyValues) {
if (value instanceof List) {
@SuppressWarnings("unchecked") final List<Object> valueList = ((List<Object>) value);
int idx = 0;
for (final Object innerValue : valueList) {
indicesStack.addLast(idx);
createPropertyValues(node, property, pr, innerValue, indicesStack, appliesToDescendantRef, dstToPropertyValues);
indicesStack.removeLast();
idx++;
}
} else {
final BusinessObjectNode dst;
boolean fullyResolved = true;
if (value instanceof ReferenceValueWithContext) {
final AadlPropertyResolutionResults rr = ((ReferenceValueWithContext) value).resolve(node, queryService);
dst = (BusinessObjectNode) rr.dst;
fullyResolved = !rr.isPartial;
} else if (value instanceof ClassifierValue) {
dst = (BusinessObjectNode) PropertyValueUtil.getReferencedClassifier(node, (ClassifierValue) value, queryService);
} else if (value instanceof InstanceReferenceValue) {
final InstanceReferenceValue irv = (InstanceReferenceValue) value;
final InstanceObject referencedInstanceObject = irv.getReferencedInstanceObject();
final AadlPropertyResolutionResults rr = PropertyValueUtil.getReferencedInstanceObject(node, referencedInstanceObject, queryService);
dst = (BusinessObjectNode) rr.dst;
fullyResolved = !rr.isPartial;
} else {
dst = null;
}
dstToPropertyValues.put(dst, new AgePropertyValue(pr, indicesStack, appliesToDescendantRef, fullyResolved));
}
}
Aggregations