Exemplo n.º 1
0
  public PropertyNode addProperty(
      String name,
      int modifiers,
      ClassNode type,
      Expression initialValueExpression,
      Statement getterBlock,
      Statement setterBlock) {
    for (PropertyNode pn : getProperties()) {
      if (pn.getName().equals(name)) {
        if (pn.getInitialExpression() == null && initialValueExpression != null)
          pn.getField().setInitialValueExpression(initialValueExpression);

        if (pn.getGetterBlock() == null && getterBlock != null) pn.setGetterBlock(getterBlock);

        if (pn.getSetterBlock() == null && setterBlock != null) pn.setSetterBlock(setterBlock);

        return pn;
      }
    }
    PropertyNode node =
        new PropertyNode(
            name, modifiers, type, redirect(), initialValueExpression, getterBlock, setterBlock);
    addProperty(node);
    return node;
  }
 private void adjustPropertyNode(PropertyNode pNode, Statement getterBody) {
   pNode.setSetterBlock(null);
   pNode.setGetterBlock(getterBody);
 }