meta.property class

Package: meta
Superclasses: meta.MetaData

Describe property of MATLAB class

Description

The meta.property class provides information about the properties of MATLAB® classes. Properties of the meta.property class contain the values of property attributes and other information that is specified syntactically in the class definition. All properties are read-only.

The meta.property class is a handle class.

Class Attributes

Abstract
true
ConstructOnLoad
true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate a meta.property object directly. Obtain a meta.property object from the meta.class PropertyList property, which contains an array of meta.property objects, one for each class property. For example, replace ClassName with the name of the class whose properties you want to query:

mco = ?ClassName;
plist = mco.PropertyList;
mp = plist(1); % meta.property for first property in list

Use the metaclass function to obtain a meta.class object from a class instance:

mco = metaclass(obj);

Properties

expand all

Property name, returned as a character vector. The meta.property Name property corresponds to the name of the associated property defined by the class.

Data Types: char

Currently not used to collect information about the class from comments.

Data Types: char

Currently not used to collect information about the class from comments.

Data Types: char

What code can query property value, returned as one of these:

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

List of classes that are allowed access to this property. Specify classes as meta.class objects in the form:

  • A single meta.class object

  • A cell array of meta.class objects. An empty cell array, {}, is the same as private access.

For more information, see Class Members Access

Example: properties (GetAccess = protected)

Data Types: enumerated | meta.class

What code can set this property value, returned as one of these:

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

immutable — property can be set only in the constructor.

For more information, see Mutable and Immutable Properties

List classes that have set access to this property. Specify classes as meta.class objects in the form:

  • A single meta.class object

  • A cell array of meta.class objects. An empty cell array, {}, is the same as private access.

See Class Members Access

Example: properties (SetAccess = protected)

Data Types: enumerated | meta.class

Does property value depends on other values, returned as logical true or false. If false (the default), property value is stored in the object. If true, the property value is not stored in the object and the set and get functions cannot access the property by indexing into the object using the property name. The value of a dependent property depends on some other value. Dependent properties must define access methods. For more information, see Set and Get Methods for Dependent Properties.

Example: properties (Dependent = true)

Data Types: logical

Is property value constant, returned as logical true or false. If true, there is only one value for this property in all instances of the class.

  • Subclasses inherit constant properties, but cannot change them.

  • Constant properties cannot be Dependent

  • SetAccess is ignored.

See Define Class Properties with Constant Values

Example: properties (Constant = true)

Data Types: logical

Is property abstract, returned as logical true or false. If true, the property has no implementation and the class is abstract.

  • Abstract properties cannot define set or get access methods. See Property Access Methods

  • Abstract properties cannot define initial values. Assigning a Default Value

  • All subclasses must specify the same values as the superclass for the property SetAccess and GetAccess attributes.

  • Abstract=true must be used with the class attribute Sealed=false (the default).

Example: properties (Abstract = true)

Data Types: logical

Is the property saved with the object, returned as logical true or false. If true, the property value is not saved when the object is saved to a MAT file. For more about saving objects, see Save and Load Process for Objects.

Example: properties (Transient = true)

Data Types: logical

Is the property hidden from the property list, returned as logical true or false. Hidden determines if the property is shown in a property list (e.g., Property Inspector, call to properties, etc.). Hidden properties are not shown in the default object display.

Example: properties (Hidden = true)

Data Types: logical

Can listeners receive property get events, returned as logical true or false. If true, and it is a handle class property, then you can create listeners that execute when the property value is queried. MATLAB calls the listeners whenever property values are queried. For more information, see Property-Set and Query Events.

Example: properties (GetObservable = true)

Data Types: logical

Can listeners receive property set events, returned as logical true or false. If true, and it is a handle class property, then you can create listeners that execute when the property value is set. MATLAB calls the listeners whenever property values are modified. For more information, see Property-Set and Query Events

Example: properties (SetObservable = true)

Data Types: logical

Is property set if value is unchanged, returned as logical true or false. If true, then setting a property value is aborted if the new value is the same as the current value. If the property belongs to a handle class, setting AbortSet to true prevents the triggering of property PreSet and PostSet events.

Example: properties (AbortSet = true)

Data Types: logical

Is property copyable, returned as logical true or false. Specify if the property value is copied when the object is copied (handle class only). By default, copying a handle object copies the concrete properties of that object. For more information, see Exclude Properties from Copy.

Example: properties (NonCopyable = true)

Data Types: logical

Priority for partial name matching, returned as a numeric value. Use with subclasses of matlab.mixin.SetGet to define the relative priority of partial property name matches used in set and get method arguments. The default value is 1. Greater values assign lower priorities.

For more information, see Set Priority for Matching Partial Property Names.

Example: properties (PartialNatchPriority = 2)

Data Types: positive integer

Property get method, returned as a function handle or an empty value. Function handle of the get method associated with this property. The value is empty if there is no get method specified in the class definition. For more information, see Property Get Methods.

Data Types: function_handle

Property set method, returned as a function handle or an empty value. Function handle of the set method associated with this property. The value is empty if there is no set method specified in the class definition. For more information, see Property Set Methods

Data Types: function_handle

Does property define a default value, returned as logical true or false. If true, the property defines a default value in the class definition. Test HasDefault before querying the DefaultValue property to avoid a MATLAB:class:NoDefaultDefined error.

Data Types: logical

Default value specified in class definition, returned as the value specified. Abstract, dependent, and dynamic properties cannot specify default values. Default values must satisfy any validation specified for the property. For more information on property validation, see Validate Property Values. If there is no default value in the class definition, MATLAB does not display the DefaultValue property.

For properties that have no default value specified in the class definition, attempting to access DefaultValue cause a MATLAB:class:NoDefaultDefined error. Use the HasDefault property to determine if the class defines a default value for the property.

Example: Prop = 7

Data Types: any

Validation defined for property, returned as a meta.Validation object. This property contains a meta.Validation object describing the validation defined by this property. If the property does not define validation, this property contains an empty meta.Validation object.

Data Types: meta.Validation

Class that defines the property, returned as a meta.class object. The meta.class object represents the class that defines this property, which can be a superclass.

Data Types: meta.class

Events

Event NameTriggerEvent DataEvent Attributes
PreGetEvent occurs just before the property value is queried.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PostGetEvent occurs just after the property value has been queried.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PreSetEvent occurs just before the property value is changed.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PostSetEvent occurs just after the property value has been changed.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

Examples

collapse all

You can use the properties of a meta.Property object to determine which class properties are read-only.

Get the meta.class object for a class named MyClass.

mc = ?MyClass;

Use findobj to search the list of meta.property objects contained in the meta.class PropertyListproperty. This call to findobj returns the name of the read-only properties.

findobj(mc.PropertyList,'GetAccess','public','-AND','-NOT','SetAccess','public').Name
Introduced in R2008a