Main Content

meta.abstractDetails

Find abstract methods and properties

Description

example

meta.abstractDetails(ClassName) displays a list of abstract methods and properties defined by the class ClassName. Use the fully qualified name for classes in packages. 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, meta.abstractDetails returns no abstract members for that class.

example

meta.abstractDetails(mc) displays a list of abstract methods and properties for the class represented by the meta.class object mc.

example

absMembers = meta.abstractDetails(___) returns an array of the 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 meta.MetaData containing meta.method and meta.property objects.

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 meta.abstractDetails on the class name. meta.abstractDetails displays the names of the abstract properties and methods defined in the class.

meta.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 meta.abstractDetails on a meta.class object representing the AbsBase class. meta.abstractDetails returns the metaclass objects for the abstract members. Use the definition of the AbsBase class from Display Abstract Member Names.

mc = ?AbsBase;
absMembers = meta.abstractDetails(mc);

absMembers is a heterogeneous array containing a meta.property object for the Prop1 abstract property and meta.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

Derive the SubAbsBase class from 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.

meta.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 a string scalar.

A meta.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 meta.MetaData containing meta.method and meta.property objects.

Version History

Introduced in R2012b