Custom class properties and method attributes
古いコメントを表示
Is there a way to add custom property or method attributes to handle classes? It is done by several classes or toolboxes, e.g. the unit testing framework allows to add tags to the methods: Tag Unit Tests - MATLAB & Simulink (mathworks.com)
classdef ExampleTagTest < matlab.unittest.TestCase
methods (Test)
function testA (testCase)
% test code
end
end
methods (Test, TestTags = {'Unit'})
function testB (testCase)
% test code
end
function testC (testCase)
% test code
end
end
I'm talking about the attributes "Test" and "TestTags".
My application would greatly benetfit from a finer granular control of properties for a DTO (data transfer object) class. I want to use argument validation but add additional options like overridable properties and don't want to use inputParser anymore :)
Thanks!
6 件のコメント
Matt J
2021 年 10 月 26 日
and don't want to use inputParser anymore
Why not? It's more flexible than argument validation.
Jan Kappen
2021 年 10 月 26 日
Matt J
2021 年 10 月 26 日
They're convenient when all the validation can be done inline, but for what you describe, it sounds like you're going to have to write your own custom validation function anyway.
Jan Kappen
2021 年 10 月 26 日
Jim Svensson
2023 年 3 月 22 日
As far as I know Matlab does not (version<=R2023) support custom property attributes. But if you are not using some of the existing ones for anything you might use them. For example SetObservable or GetObservable can be used to mean something else if you are not using listeners.
Jan Kappen
2023 年 3 月 22 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Class Introspection and Metadata についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!