You need to sign in to do that
Don't have an account?

How to list inheriting classes from an abstract class
Hi ,
I'm struggling with SF docs / forums / google and I don't succeed to find a response to a simple question:
How to list classes inheriting from a super class ?
Example :
I need to be able to create a method who can return 'MyFirstChildClassLabel','MySecondChildClassLabel'
I anyone is able to fill the blank part in my code, I would be enternally thankful :)
Note: some code parts are missing about interface management but it's ok i know how to manage it :)
Many thanks , best regards & have a nice day :)
I'm struggling with SF docs / forums / google and I don't succeed to find a response to a simple question:
How to list classes inheriting from a super class ?
Example :
public abstract MyRootAbstractClass { public virtual String getLabel() {return null ;} } public class MyFirstChildClass extends MyRootAbstractClass { public override String getLabel() {return 'MyFirstChildClassLabel' ;} } public class MySecondChildClass extends MyRootAbstractClass { public override String getLabel() {return 'MySecondChildClassLabel' ;} }
I need to be able to create a method who can return 'MyFirstChildClassLabel','MySecondChildClassLabel'
I anyone is able to fill the blank part in my code, I would be enternally thankful :)
Type RootClassType = Type.forName('MyRootAbstractClass'); ///// // WHAT TO PUT HERE ??? :'( ///// List<String> AvailableChildClassList = new List<String>(); for (String ChildClass : ChildClassList) { ClassType = Type.forName(ChildClass); SomeInterface ClassInstance = (SomeInterface)ClassType.newInstance(); String ChildClassLabel = ClassInstance.getLabel(); AvailableChildClassList.add(ChildClassLabel); } return AvailableChildClassList;
Note: some code parts are missing about interface management but it's ok i know how to manage it :)
Many thanks , best regards & have a nice day :)
This may be late reply..
Best Regards.
Amit Ghadage