Created
June 14, 2016 05:39
-
-
Save jfmherokiller/2b0d359650ab34006256f92cdb5a3991 to your computer and use it in GitHub Desktop.
Hacky Switch Statement Prototype
This file contains hidden or 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
import java.util.ArrayList; | |
/** | |
* Created by jfmmeyers on 6/14/16. | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
ArrayList<Pair<String,String>> casencodelist = new ArrayList<>(); | |
casencodelist.add(new Pair<String, String>("default","console.log(boobies)")); | |
} | |
} |
This file contains hidden or 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
/** | |
* Created by jfmmeyers on 6/14/16. | |
*/ | |
public class Pair<L,R> { | |
private L l; | |
private R r; | |
public Pair(L l, R r){ | |
this.l = l; | |
this.r = r; | |
} | |
public L getL(){ return l; } | |
public R getR(){ return r; } | |
public void setL(L l){ this.l = l; } | |
public void setR(R r){ this.r = r; } | |
} |
This file contains hidden or 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
import java.util.ArrayList; | |
/** | |
* Created by jfmmeyers on 6/14/16. | |
*/ | |
public class SwitchClass { | |
ArrayList<Pair<String,String>> casesnandcodes; | |
SwitchClass (ArrayList<Pair<String,String>> stuff) | |
{ | |
casesnandcodes = stuff; | |
} | |
public void callswitch(String switchcase) | |
{ | |
for( Pair<String,String> thing : casesnandcodes) | |
{ | |
if (switchcase.equals(thing.getL())) | |
{ | |
//TODO: put eval thing here | |
//window.eval(thing.getR()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment