Main Content

hasStereotype

Find if element has stereotype applied

Since R2021a

    Description

    result = hasStereotype(element,stereotype) returns true if the stereotype stereotype has been applied on the model element element.

    example

    Examples

    collapse all

    Create a model with a component.

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

    Create a profile with a stereotype and properties, open the Profile Editor, then apply the profile to the model.

    profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");
    latencybase = profile.addStereotype("LatencyBase");
    latencybase.addProperty("latency",Type="double");
    latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
    systemcomposer.profile.editor(profile)
    model.applyProfile("LatencyProfile");

    Apply the stereotype to the component. Find if the stereotypes are applied on the component.

    comp.applyStereotype("LatencyProfile.LatencyBase");
    result = hasStereotype(comp,"LatencyProfile.LatencyBase")
    result =
    
      logical
    
       1

    Input Arguments

    collapse all

    Stereotype, specified as a character vector or string in the form "<profile>.<stereotype>" or a systemcomposer.profile.Stereotype object.

    Data Types: char | string

    Output Arguments

    collapse all

    Query result, returned as 1 (true) or 0 (false).

    Data Types: logical

    More About

    collapse all

    Version History

    Introduced in R2021a