Skip to content

Instantly share code, notes, and snippets.

@markgarg
Created February 18, 2015 14:23
Show Gist options
  • Save markgarg/be60cd6c7aaad8a7d4a5 to your computer and use it in GitHub Desktop.
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
// 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'));
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;
}
}
// 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