antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
955 stars 231 forks source link

if object properties start with 'r', it dose not work #170

Closed otary closed 7 years ago

otary commented 7 years ago

example:

public class Staff  {
    private String rType;
    public String getrType() {
    return rType;
   }

  public void setrType(String rType) {
    this.rType = rType;
 }

public Staff(String rType) {
    this.rType = rType;
}
}
ST st = new ST("<s.rType>");
st.add("s", new Staff("22"));
System.out.println(st.render()); //return no data

why? The Object properties can not start with 'r'?

jeff5 commented 7 years ago

StringTemplate uses JavaBeans conventions, so your accessor for Staff.rType should be called getRType (and setRType).

sharwell commented 7 years ago

@jeff5 is correct! (and thanks for answering so quickly)