MATLAB Object-Oriented Programming

(Joyce) #1

Find Default Values in Property Metadata


In this section...
“Default Values” on page 16-20
“meta.property Data” on page 16-20

Default Values


Class definitions can specify explicit default values for properties (see “Property Default
Values” on page 8-18). Determine if a class defines an explicit default value for a property
and what the value of the default is from the property meta.property object.

meta.property Data


The meta.class object for a class contains a meta.property object for every property
defined by the class, including properties with private and protected access.

For example, get the meta.class object for the PropertyWithDefault class shown
here:

classdef PropertyWithDefault
properties
Date = date
RandNumber = randi(9)
end
end

Get an array of meta.property objects from the meta.class object:

mc = ?PropertyWithDefault; % meta.class object
mp = mc.PropertyList; % meta.property array

The second element in the mp array is the meta.property object for the RandNumber
property. Listing the meta.property object shows the information contained in its
properties:

mp(2)

property with properties:

16 Information from Class Metadata

Free download pdf