package st.gravel.support.compiler.ast;

/*
	This file is automatically generated from typed smalltalk source. Do not edit by hand.
	(C) AG5.com
*/

import java.math.BigInteger;
import st.gravel.support.jvm.NonLocalReturn;
import st.gravel.support.compiler.ast.MethodNode;
import st.gravel.support.compiler.ast.ClassDescriptionNode;

public class UpdateClassDescriptorDiff extends Object implements Cloneable {

	public static UpdateClassDescriptorDiff_Factory factory = new UpdateClassDescriptorDiff_Factory();

	String[] _deletedSelectors;

	MethodNode[] _methodNodes;

	MethodNode[] _updatedMethodNodes;

	public static class UpdateClassDescriptorDiff_Factory extends st.gravel.support.jvm.SmalltalkFactory {

		public UpdateClassDescriptorDiff basicNew() {
			UpdateClassDescriptorDiff newInstance = new UpdateClassDescriptorDiff();
			newInstance.initialize();
			return newInstance;
		}

		public UpdateClassDescriptorDiff empty() {
			return this.methodNodes_updatedMethodNodes_deletedSelectors_(new MethodNode[] {}, new MethodNode[] {}, new String[] {});
		}

		public UpdateClassDescriptorDiff methodNodes_updatedMethodNodes_deletedSelectors_(final MethodNode[] _anArray, final MethodNode[] _anArray2, final String[] _anArray3) {
			return this.basicNew().initializeMethodNodes_updatedMethodNodes_deletedSelectors_(_anArray, _anArray2, _anArray3);
		}
	}

	static public UpdateClassDescriptorDiff _empty(Object receiver) {
		return factory.empty();
	}

	static public UpdateClassDescriptorDiff _methodNodes_updatedMethodNodes_deletedSelectors_(Object receiver, final MethodNode[] _anArray, final MethodNode[] _anArray2, final String[] _anArray3) {
		return factory.methodNodes_updatedMethodNodes_deletedSelectors_(_anArray, _anArray2, _anArray3);
	}

	public ClassDescriptionNode applyOnClassNode_(final ClassDescriptionNode _startClassNode) {
		ClassDescriptionNode _classNode;
		_classNode = ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_methodNodes, _startClassNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>() {

			@Override
			public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final MethodNode _m) {
				return (ClassDescriptionNode) _cn.withMethodNode_(_m);
			}
		}))));
		_classNode = ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_updatedMethodNodes, _classNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>() {

			@Override
			public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final MethodNode _m) {
				return (ClassDescriptionNode) _cn.copyReplaceMethodNode_(_m);
			}
		}))));
		return ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_deletedSelectors, _classNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, String>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, String>() {

			@Override
			public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final String _sel) {
				return (ClassDescriptionNode) _cn.copyRemoveSelector_(_sel);
			}
		}))));
	}

	public UpdateClassDescriptorDiff copy() {
		try {
			UpdateClassDescriptorDiff _temp1 = (UpdateClassDescriptorDiff) this.clone();
			_temp1.postCopy();
			return _temp1;
		} catch (CloneNotSupportedException e) {
			throw new RuntimeException(e);
		}
	}

	public String[] deletedSelectors() {
		return _deletedSelectors;
	}

	public UpdateClassDescriptorDiff_Factory factory() {
		return factory;
	}

	public UpdateClassDescriptorDiff initialize() {
		return this;
	}

	public UpdateClassDescriptorDiff initializeMethodNodes_updatedMethodNodes_deletedSelectors_(final MethodNode[] _anArray, final MethodNode[] _anArray2, final String[] _anArray3) {
		_methodNodes = _anArray;
		_updatedMethodNodes = _anArray2;
		_deletedSelectors = _anArray3;
		this.initialize();
		return this;
	}

	public boolean isEmpty() {
		return (_methodNodes.length == 0) && ((_updatedMethodNodes.length == 0) && (_deletedSelectors.length == 0));
	}

	public MethodNode[] methodNodes() {
		return _methodNodes;
	}

	public UpdateClassDescriptorDiff postCopy() {
		return this;
	}

	public UpdateClassDescriptorDiff pvtSetDeletedSelectors_(final String[] _anArray) {
		_deletedSelectors = _anArray;
		return this;
	}

	public UpdateClassDescriptorDiff pvtSetMethodNodes_(final MethodNode[] _anArray) {
		_methodNodes = _anArray;
		return this;
	}

	public UpdateClassDescriptorDiff pvtSetUpdatedMethodNodes_(final MethodNode[] _anArray) {
		_updatedMethodNodes = _anArray;
		return this;
	}

	public MethodNode[] updatedMethodNodes() {
		return _updatedMethodNodes;
	}

	public UpdateClassDescriptorDiff withAddMethodNode_(final MethodNode _aMethodNode) {
		return this.copy().pvtSetMethodNodes_(st.gravel.support.jvm.ArrayExtensions.copyWith_(_methodNodes, _aMethodNode));
	}

	public UpdateClassDescriptorDiff withDeletedSelector_(final String _aString) {
		return this.copy().pvtSetDeletedSelectors_(st.gravel.support.jvm.ArrayExtensions.copyWith_(_deletedSelectors, _aString));
	}

	public UpdateClassDescriptorDiff withUpdateMethodNode_(final MethodNode _aMethodNode) {
		return this.copy().pvtSetUpdatedMethodNodes_(st.gravel.support.jvm.ArrayExtensions.copyWith_(_updatedMethodNodes, _aMethodNode));
	}
}
