Skip to content

Instantly share code, notes, and snippets.

@jfmherokiller
Created June 14, 2016 05:39
Show Gist options
  • Save jfmherokiller/2b0d359650ab34006256f92cdb5a3991 to your computer and use it in GitHub Desktop.
Save jfmherokiller/2b0d359650ab34006256f92cdb5a3991 to your computer and use it in GitHub Desktop.
Hacky Switch Statement Prototype
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)"));
}
}
/**
* 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; }
}
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