if (classNode.getField(fieldName) == null) {
classNode.addField(fieldName, Modifier.PRIVATE, targetClass.getType(),null);
}
MethodNode methodNode = classNode.getDeclaredMethod(methodName,GrailsArtefactClassInjector.ZERO_PARAMETERS);
VariableExpression fieldExpression = new VariableExpression(fieldName, targetClass.getType());
if (methodNode == null) {
BlockStatement setupMethodBody = new BlockStatement();
addMockCollaborator(type, targetClass, setupMethodBody);
methodNode = new MethodNode(methodName, Modifier.PUBLIC, ClassHelper.VOID_TYPE, GrailsArtefactClassInjector.ZERO_PARAMETERS,null, setupMethodBody);
methodNode.addAnnotation(BEFORE_ANNOTATION);
methodNode.addAnnotation(MIXIN_METHOD_ANNOTATION);
classNode.addMethod(methodNode);
GrailsASTUtils.addCompileStaticAnnotation(methodNode);
}
MethodNode getter = classNode.getDeclaredMethod(getterName, GrailsArtefactClassInjector.ZERO_PARAMETERS);
if (getter == null) {
BlockStatement getterBody = new BlockStatement();
getter = new MethodNode(getterName, Modifier.PUBLIC, targetClass.getType().getPlainNodeReference(),GrailsArtefactClassInjector.ZERO_PARAMETERS,null, getterBody);
BinaryExpression testTargetAssignment = new BinaryExpression(fieldExpression, ASSIGN, new ConstructorCallExpression(targetClass.getType(), GrailsArtefactClassInjector.ZERO_ARGS));
IfStatement autowiringIfStatement = getAutowiringIfStatement(targetClass,fieldExpression, testTargetAssignment);
getterBody.addStatement(autowiringIfStatement);