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 injectAssociationProperties(ClassNode classNode, List propertiesToAdd) {
   for (Iterator i = propertiesToAdd.iterator(); i.hasNext(); ) {
     PropertyNode pn = (PropertyNode) i.next();
     if (! /*GrailsASTUtils.*/hasProperty(classNode, pn.getName())) {
       // if(LOG.isDebugEnabled()) {
       //    LOG.debug("[GrailsDomainInjector] Adding property [" + pn.getName() + "] to class [" +
       // classNode.getName() + "]");
       // }
       classNode.addProperty(pn);
     }
   }
 }
 private void addProperty(ClassNode cNode, PropertyNode pNode) {
   final FieldNode fn = pNode.getField();
   cNode.getFields().remove(fn);
   cNode.addProperty(
       pNode.getName(),
       pNode.getModifiers() | ACC_FINAL,
       pNode.getType(),
       pNode.getInitialExpression(),
       pNode.getGetterBlock(),
       pNode.getSetterBlock());
   final FieldNode newfn = cNode.getField(fn.getName());
   cNode.getFields().remove(newfn);
   cNode.addField(fn);
 }
  private void injectIdProperty(ClassNode classNode) {
    final boolean hasId = /*GrailsASTUtils.*/
        hasProperty(classNode, /*GrailsDomainClassProperty.*/ IDENTITY);

    if (!hasId) {
      // if(LOG.isDebugEnabled()) {
      //    LOG.debug("[GrailsDomainInjector] Adding property [" +
      // GrailsDomainClassProperty.IDENTITY + "] to class [" + classNode.getName() + "]");
      // }
      classNode.addProperty(
          /*GrailsDomainClassProperty.*/ IDENTITY,
          Modifier.PUBLIC,
          new ClassNode(Long.class),
          null,
          null,
          null);
    }
  }
  private void injectVersionProperty(ClassNode classNode) {
    final boolean hasVersion = /*GrailsASTUtils.*/
        hasProperty(classNode, /*GrailsDomainClassProperty.*/ VERSION);

    if (!hasVersion) {
      // if(LOG.isDebugEnabled()) {
      //    LOG.debug("[GrailsDomainInjector] Adding property [" + GrailsDomainClassProperty.VERSION
      // + "] to class [" + classNode.getName() + "]");
      // }
      classNode.addProperty(
          /*GrailsDomainClassProperty.*/ VERSION,
          Modifier.PUBLIC,
          new ClassNode(Long.class),
          null,
          null,
          null);
    }
  }