Created
May 29, 2013 06:08
-
-
Save greenlaw110/5668267 to your computer and use it in GitHub Desktop.
Rythm Dynamic Expression Evaluation
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
@Test | |
public void testDynamicExpr() { | |
System.setProperty(CODEGEN_DYNAMIC_EXP.getKey(), "true"); | |
JavaBean bean = new JavaBean("foo", 11, true); | |
bean.set("engine", "Rythm"); | |
t = "@b.id|@b.count|@b.enabled|@b.engine"; | |
Map<String, Object> params = new HashMap<String, Object>(); | |
params.put("b", bean); | |
s = r(t, params); | |
eq("foo|11|true|Rythm"); | |
} |
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
public class JavaBean { | |
private String id; | |
private int count; | |
private boolean enabled; | |
private Map<String, Object> attrs; | |
public JavaBean(String id, int count, boolean enabled) { | |
this.id = id; | |
this.count = count; | |
this.enabled = enabled; | |
attrs = new HashMap<String, Object>(); | |
} | |
public String getId() { | |
return id; | |
} | |
public int getCount() { | |
return count; | |
} | |
public boolean isEnabled() { | |
return enabled; | |
} | |
public void set(String key, Object val) { | |
attrs.put(key, val); | |
} | |
public Object get(String key) { | |
return attrs.get(key); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment