use of org.palladiosimulator.pcm.parameter.VariableUsage in project Palladio-Editors-Sirius by PalladioSimulator.
the class ComposedProvidingRequiringEntityServices method getVariableUsages.
/**
* Returns a list containing all {@link VariableUsage}s associated with the
* {@link AssemblyContext}. This means all usages that are defined on the context itself and
* those of its encapsulated component which are not overwritten.
*
* @param assemblyContext
* AssemblyContext
* @return associated VariableUsages
* @see #isOverridden(VariableUsage, AssemblyContext)
*/
public Collection<EObject> getVariableUsages(final AssemblyContext assemblyContext) {
final Collection<EObject> usages = new HashSet<>();
// only ImplementationComponentTypes can have VariableUsages
if (!(assemblyContext.getEncapsulatedComponent__AssemblyContext() instanceof ImplementationComponentType))
return usages;
final Collection<VariableUsage> componentVariableUsages = ((ImplementationComponentType) assemblyContext.getEncapsulatedComponent__AssemblyContext()).getComponentParameterUsage_ImplementationComponentType();
// combine the sets
usages.addAll(assemblyContext.getConfigParameterUsages__AssemblyContext());
for (final VariableUsage vu : componentVariableUsages) {
if (!isOverridden(vu, assemblyContext)) {
usages.add(vu);
}
}
return usages;
}
use of org.palladiosimulator.pcm.parameter.VariableUsage in project Palladio-Editors-Sirius by PalladioSimulator.
the class ComposedProvidingRequiringEntityServices method copyToAssemblyContext.
/**
* Copies the {@link VariableUsage} to the {@link AssemblyContext}, i.e. 'instantiates' it. This
* method will return the original VariableUsage.
*
* @param variableUsage
* the VariableUsage to be copied
* @param assemblyContext
* the target AssemblyContext
* @return the original VariableUsage
*/
public EObject copyToAssemblyContext(final VariableUsage variableUsage, final AssemblyContext assemblyContext) {
final List<EObject> copiedVariableUsage = EMFCopyHelper.deepCopyEObjectList(Collections.singletonList(variableUsage));
if (copiedVariableUsage.size() != 1 || !(copiedVariableUsage.get(0) instanceof VariableUsage))
return null;
final VariableUsage newVariableUsage = (VariableUsage) copiedVariableUsage.get(0);
newVariableUsage.setAssemblyContext__VariableUsage(assemblyContext);
assemblyContext.getConfigParameterUsages__AssemblyContext().add(newVariableUsage);
return variableUsage;
}
Aggregations