Main Content

hasProperty

Find if element has property

Since R2021a

    Description

    result = hasProperty(element,property) returns true if the property property has been added on the model element element.

    example

    Examples

    collapse all

    Get the weight property from a component with the sysComponent stereotype applied.

    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 profile with a stereotype and a property, then apply the profile to the model.

    profile = systemcomposer.profile.Profile.createProfile("sysProfile");
    base = profile.addStereotype("sysComponent");
    base.addProperty("weight",Type="double",DefaultValue="10",Units="g");
    model.applyProfile("sysProfile")

    Apply the stereotype to the component, then set a new weight property.

    applyStereotype(comp,"sysProfile.sysComponent")
    setProperty(comp,"sysProfile.sysComponent.weight","5","g")

    Find if the weight property exists on the component.

    result = hasProperty(comp,"sysProfile.sysComponent.weight")
    
    result =
    
      logical
    
       1

    Input Arguments

    collapse all

    Property, specified as a character vector or string in the form "<profile>.<stereotype>.<property>".

    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