示例#1
0
  public void addBeanField(String name, TClassType type) {
    classType.getFields().add(new TField(classType, name, type, Modifier.PRIVATE | Modifier.FINAL));

    TMethod getterMethod =
        new TMethod(classType, RenderUtil.getGetterName(type, name), type, Modifier.PUBLIC);
    getterMethod.setMethodContents("return this." + name + ";\n");
    classType.getMethods().add(getterMethod);

    TMethod setterMethod =
        new TMethod(classType, RenderUtil.getSetterName(name), type, Modifier.PUBLIC);
    setterMethod.addParameter(name, type, Modifier.FINAL);
    setterMethod.setMethodContents("this." + name + " = " + name + ";\n");
    classType.getMethods().add(setterMethod);
  }