Skip to content

ApexClassUtilities

pozil edited this page Nov 14, 2024 · 19 revisions

ApexClassUtilities Class

Contains reusable code dealing with ApexClass objects. This is primarily used by the LWC components for displaying code in an org.

Group Shared Code

See RecipeTreeViewController

See FormattedRecipeDisplayController

Methods

getGroupFromClassBody(klass)

Extracts the @group annotation from a class' body. Also demonstrates the use of Regex matchers in Apex.

Signature

public static String getGroupFromClassBody(ApexClass klass)

Parameters

Name Type Description
klass ApexClass an ApexClass object

Return Type

String

Text following ,[object Object], through the end of the line.

Example

ApexClass klass = [SELECT Name, Body FROM ApexClass LIMIT 1];
System.debug(ApexClassUtilities.getGroupFromClassBody(klass));

getRelatedClassesFromClassBody(klass)

Extracts the @see annotations from a class' body. Also demonstrates the use of Regex matchers in Apex.

Signature

public static List<String> getRelatedClassesFromClassBody(ApexClass klass)

Parameters

Name Type Description
klass ApexClass an ApexClass object

Return Type

List<String>

Values following ,[object Object], annotations

Example

ApexClass klass = [SELECT Name, Body FROM ApexClass LIMIT 1];
System.debug(ApexClassUtilities.getRelatedClassesFromClassBody(klass));
Clone this wiki locally