Created
February 18, 2015 14:23
-
-
Save markgarg/be60cd6c7aaad8a7d4a5 to your computer and use it in GitHub Desktop.
Sample code to check whether Dynamic Apex works with params. The input param is printed in the method => Dynamic Apex works with params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the Type corresponding to the class name | |
Type t = Type.forName('DummyTypeInstantiableOne'); | |
// Instantiate the type. | |
// The type of the instantiated object | |
// is the interface. | |
DummyTypeInstantiableOne dtiOne = (DummyTypeInstantiableOne) t.newInstance(); | |
// Call the methods that have a custom implementation | |
System.debug('Output for the method :' + dtiOne.processRule('one')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class DummyTypeInstantiableOne implements TypeInstantiable { | |
public DummyTypeInstantiableOne() { | |
} | |
// Implementing the interface method | |
public Boolean processRule(String input){ | |
System.debug('DummyTypeInstantiableOne String input :' + input); | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To test the execution of method based on class | |
public interface TypeInstantiable { | |
Boolean processRule(String input); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment