Skip to content

Instantly share code, notes, and snippets.

@greenlaw110
Created May 29, 2013 06:08
Show Gist options
  • Save greenlaw110/5668267 to your computer and use it in GitHub Desktop.
Save greenlaw110/5668267 to your computer and use it in GitHub Desktop.
Rythm Dynamic Expression Evaluation
@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");
}
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