Main Content

matlab.metadata.abstractDetails

Find abstract methods and properties

Renamed from meta.abstractDetails in R2024a

Description

matlab.metadata.abstractDetails(ClassName) displays a list of abstract methods and properties defined by the class ClassName. 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) displays a list of abstract methods and properties for the class represented by the matlab.metadata.Class object mc.

example

absMembers = 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 and matlab.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 a matlab.metadata.Class object representing the AbsBase class. matlab.metadata.abstractDetails returns the metaclass objects for the abstract members. Use the definition of the AbsBase class from Display Abstract Member Names.

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

absMembers is a heterogeneous array containing a matlab.metadata.Property object for the Prop1 abstract property and matlab.metadata.Method objects for the methodOne 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 of AbsBase, 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 by SubAbsBase. 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