Use Property Descriptors in a Description

This tutorial shows how to use PropertyDescriptors within a description.

Step 1: Open or create an entity description

Open or recreate the "Demo" source description so you have something to work with.

classdef Demo < symphonyui.core.persistent.descriptions.SourceDescription

    methods

        function obj = Demo()
            obj.addProperty('id', '');
            obj.addProperty('sex', '');
        end

    end

end

Step 2: Constrain property values

Edit the line where you add the "id" property to specify a PropertyType that constrains the value to a double.

obj.addProperty('id', 0, ...
    'type', symphonyui.core.PropertyType('denserealdouble', 'scalar'));
Note: You must change the initial value to 0 because you are specifying a "denserealdouble" PropertyType and the initial value must now be a denserealdouble.

Edit the line where you add the "sex" property to specify a PropertyType that constrains the value to a selection of possible values.

obj.addProperty('sex', '', ...
    'type', symphonyui.core.PropertyType('char', 'row', {'', 'male', 'female', 'hermaphrodite'}));

Now if you add a source using the "Demo" description you will see that the property values are constrained by the types you specified.

constrained

results matching ""

    No results matching ""