Created
August 30, 2018 12:34
-
-
Save amitkumarRoy/ba418aa812583b4aa59201c3b1840e5d to your computer and use it in GitHub Desktop.
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 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