-
-
Save noeticpenguin/cd457c5b969b48b1f28a 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 Dynamic { | |
public class IntentionalException extends Exception{} | |
public static boolean eval(String toEval){ | |
boolean result = false; | |
if(!toEval.startsWith('if')) { | |
toEval = 'if(' + toEval + ') {throw new Dynamic.IntentionalException(\'true\');} else {throw new Dynamic.IntentionalException(\'false\');}'; | |
} | |
ToolingAPI x = new ToolingAPI(); | |
try{ | |
ToolingAPI.ExecuteAnonymousResult toolingResult = x.executeAnonymousUnencoded(toEval); | |
} catch (IntentionalException ie) { | |
result = (ie.getMessage() == 'true') ? True : False; | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment