matlab.metadata.abstractDetails - Find abstract methods and properties - MATLAB (original) (raw)

Main Content

Find abstract methods and properties

Renamed from meta.abstractDetails in R2024a

Syntax

Description

matlab.metadata.abstractDetails([ClassName](#mw%5Fd2486d35-cb86-4088-9dcf-e48b28127180)) displays a list of abstract methods and properties defined by the classClassName. Use the fully qualified name for classes in namespaces. MATLABĀ® displays all public and protected abstract methods and properties, including those declared Hidden.

A class can be abstract without defining any abstract methods or properties if it declares the Abstract class attribute. In this case,matlab.metadata.abstractDetails returns no abstract members for that class.

example

matlab.metadata.abstractDetails([mc](#mw%5F5e53c0e4-51f7-4abd-94d9-b6acca788cc1)) displays a list of abstract methods and properties for the class represented by the matlab.metadata.Class object mc.

example

[absMembers](#mw%5Fee11f0d1-aecc-4bb2-a120-352c6c56fe3c) = matlab.metadata.abstractDetails(___) returns an array of metaclass objects corresponding to the abstract members of the class. This syntax accepts either of the previously listed input arguments.

When the class has both abstract methods and abstract properties,absMembers is a heterogeneous array of class matlab.metadata.MetaData containing matlab.metadata.Method andmatlab.metadata.Property objects.

example

Examples

collapse all

Define the class AbsBase with an abstract property and two abstract methods.

classdef AbsBase properties (Abstract) Prop1 end methods(Abstract) result = methodOne(obj) output = methodTwo(obj) end end

Call matlab.metadata.abstractDetails on the class name.matlab.metadata.abstractDetails displays the names of the abstract properties and methods defined in the class.

matlab.metadata.abstractDetails("AbsBase")

Abstract methods for class AbsBase: methodTwo % defined in AbsBase methodOne % defined in AbsBase

Abstract properties for class AbsBase: Prop1 % defined in AbsBase

Call matlab.metadata.abstractDetails on amatlab.metadata.Class object representing theAbsBase class. matlab.metadata.abstractDetails returns the metaclass objects for the abstract members. Use the definition of theAbsBase class from Display Abstract Member Names.

mc = ?AbsBase; absMembers = matlab.metadata.abstractDetails(mc);

absMembers is a heterogeneous array containing amatlab.metadata.Property object for the Prop1 abstract property and matlab.metadata.Method objects for themethodOne and methodTwo abstract methods.

List the names of the metaclass objects.

for k = 1:length(absMembers) disp(absMembers(k).Name) end

methodTwo methodOne Prop1

Define the SubAbsBase class as a subclass ofAbsBase, which is defined in Display Abstract Member Names.

classdef SubAbsBase < AbsBase properties SubProp = 1; end methods function result = methodOne(obj) result = obj.SubProp + 1; end end end

Display the names of the abstract members inherited bySubAbsBase. Because methodOne is overridden as a concrete method in SubAbsBase, it is not included in the list of abstract members.

matlab.metadata.abstractDetails("SubAbsBase")

Abstract methods for class SubAbsBase: methodTwo % defined in AbsBase

Abstract properties for class SubAbsBase: Prop1 % defined in AbsBase

Input Arguments

collapse all

Name of the class being investigated, specified as a character vector or string scalar.

A matlab.metadata.Class object representing the class being investigated.

Output Arguments

collapse all

Array of metaclass objects representing abstract properties and methods. When the class has both abstract methods and abstract properties, absMembers is a heterogeneous array of class matlab.metadata.MetaData containing matlab.metadata.Method and matlab.metadata.Property objects.

Version History

Introduced in R2012b

expand all

The namespace of abstractDetails has been changed frommeta to matlab.metadata. The behavior remains the same, but MATLAB warns when the old function name is used. The recommended practice is to update this name in your code, even though MATLAB will continue to recognize the old name.