Skip to content

Instantly share code, notes, and snippets.

@amitkumarRoy
Created August 30, 2018 12:34
Show Gist options
  • Save amitkumarRoy/ba418aa812583b4aa59201c3b1840e5d to your computer and use it in GitHub Desktop.
Save amitkumarRoy/ba418aa812583b4aa59201c3b1840e5d to your computer and use it in GitHub Desktop.
public class Extension implements Callable {
// Actual method
String concatStrings(String stringValue) {
return stringValue + stringValue;
}
// Actual method
Decimal multiplyNumbers(Decimal decimalValue) {
return decimalValue * decimalValue;
}
// Dispatch actual methods
public Object call(String action, Map<String, Object> args) {
switch on action {
when 'concatStrings' {
return this.concatStrings((String)args.get('stringValue'));
}
when 'multiplyNumbers' {
return this.multiplyNumbers((Decimal)args.get('decimalValue'));
}
when else {
throw new ExtensionMalformedCallException('Method not implemented');
}
}
}
public class ExtensionMalformedCallException extends Exception {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment