Main Content

changeStereotype

Change currently applied stereotype to new stereotype in its stereotype hierarchy

Since R2024a

    Description

    changeStereotype(element,stereotype,Name=Value) changes the currently applied stereotype on an architectural element to another stereotype in its stereotype hierarchy with an optional name-value argument. Changing stereotypes retains shared property values.

    example

    Examples

    collapse all

    Change stereotypes applied to a component by going down the hierarchy of stereotypes you define in the profile.

    Create a model with a component called Component.

    model = systemcomposer.createModel("archModel");
    systemcomposer.openModel("archModel");
    arch = get(model,"Architecture");
    comp = addComponent(arch,"Component");

    Create a new profile and apply the profile to your model.

    profile = systemcomposer.profile.Profile.createProfile("SoftwareProfile");
    model.applyProfile("SoftwareProfile")

    Create an inheritance hierarchy among the stereotypes in the profile, then save the profile and model.

    baseComp = profile.addStereotype('BaseComponent');
    swComp = profile.addStereotype('SoftwareComponent',...
    'Parent',baseComp.FullyQualifiedName);
    profile.addStereotype('AppSWComponent',...
    'Parent',swComp.FullyQualifiedName);
    profile.addStereotype('DeviceSWComponent',...
    'Parent',swComp.FullyQualifiedName);
    profile.addStereotype('HardwareComponent',...
    'Parent',baseComp.FullyQualifiedName);
    
    profile.save; model.save

    Apply the BaseComponent stereotype to the Component component.

    comp.Architecture.applyStereotype("SoftwareProfile.BaseComponent")

    Change the BaseComponent stereotype on the Component component to the AppSWComponent stereotype. Then, get all stereotypes applied to the Component component.

    comp.Architecture.changeStereotype("SoftwareProfile.AppSWComponent")
    stereotypes = getStereotypes(comp)
    stereotypes =
      1×1 cell array
        {'SoftwareProfile.AppSWComponent'}

    Input Arguments

    collapse all

    Name of the stereotype, specified as a character vector or string in the form "<profile>.<stereotype>". The profile must already be imported into the model.

    Data Types: char | string

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: comp.Architecture.changeStereotype("SoftwareProfile.AppSWComponent",Source="SoftwareProfile.BaseComponent")

    Stereotype to change, specified as a character vector pr string in the form "<profile>.<stereotype>".

    Data Types: char | string

    Option to force the stereotype to change even if there is a loss of data, specified as 1 (true) or 0 (false).

    Data Types: logical

    More About

    collapse all

    Version History

    Introduced in R2024a