use of org.osate.aadl2.StringLiteral in project osate2 by osate.
the class PropertyUtils method getStringValue.
/**
* Extract String value from a specified property. May return null.
*
* @param i
* component instance.
* @param propertyName
* property name.
* @return property value.
*/
public static String getStringValue(NamedElement i, String propertyName) {
PropertyAssociation pa = findPropertyAssociation(propertyName, i);
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 StringLiteral) {
return ((StringLiteral) expr).getValue();
}
}
}
}
return null;
}
use of org.osate.aadl2.StringLiteral in project osate2 by osate.
the class ProgrammingProperties method getSourceName.
public static Optional<String> getSourceName(NamedElement lookupContext, Optional<Mode> mode) {
Property property = getSourceName_Property(lookupContext);
try {
PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
return Optional.of(((StringLiteral) resolved).getValue());
} catch (PropertyNotPresentException e) {
return Optional.empty();
}
}
use of org.osate.aadl2.StringLiteral in project osate2 by osate.
the class ProgrammingProperties method getSourceText.
public static Optional<List<String>> getSourceText(NamedElement lookupContext, Optional<Mode> mode) {
Property property = getSourceText_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 ((StringLiteral) resolved1).getValue();
}).collect(Collectors.toList()));
} catch (PropertyNotPresentException e) {
return Optional.empty();
}
}
use of org.osate.aadl2.StringLiteral in project osate2 by osate.
the class ProgrammingProperties method getHardwareDescriptionSourceText.
public static Optional<List<String>> getHardwareDescriptionSourceText(NamedElement lookupContext, Optional<Mode> mode) {
Property property = getHardwareDescriptionSourceText_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 ((StringLiteral) resolved1).getValue();
}).collect(Collectors.toList()));
} catch (PropertyNotPresentException e) {
return Optional.empty();
}
}
use of org.osate.aadl2.StringLiteral in project osate2 by osate.
the class ProgrammingProperties method getFinalizeEntrypointSourceText.
public static Optional<String> getFinalizeEntrypointSourceText(NamedElement lookupContext, Optional<Mode> mode) {
Property property = getFinalizeEntrypointSourceText_Property(lookupContext);
try {
PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
return Optional.of(((StringLiteral) resolved).getValue());
} catch (PropertyNotPresentException e) {
return Optional.empty();
}
}
Aggregations