All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.duelengine.duel.codedom.CodeConstructor Maven / Gradle / Ivy

There is a newer version: 0.9.7
Show newest version
package org.duelengine.duel.codedom;

import java.util.ArrayList;
import java.util.List;

public class CodeConstructor extends CodeMethod {

	private final List baseCtorArgs = new ArrayList();
	private final List chainedCtorArgs = new ArrayList();

	public CodeConstructor() {
		setName(".ctor");
	}

	public CodeConstructor(AccessModifierType access, CodeParameterDeclarationExpression[] parameters, CodeExpression[] baseCtorArgs, CodeExpression[] chainedCtorArgs, CodeStatement[] statements) {
		super(access, Void.class, ".ctor", parameters, statements);

		if (baseCtorArgs != null) {
			for (CodeExpression arg : baseCtorArgs) {
				this.baseCtorArgs.add(arg);
			}
		}

		if (chainedCtorArgs != null) {
			for (CodeExpression arg : chainedCtorArgs) {
				this.chainedCtorArgs.add(arg);
			}
		}
	}

	public List getBaseCtorArgs() {
		return baseCtorArgs;
	}

	public List getChainedCtorArgs() {
		return chainedCtorArgs;
	}

	@Override
	public void visit(CodeVisitor visitor) {
		if (visitor.visit(this)) {
			for (CodeParameterDeclarationExpression parameter : getParameters()) {
				if (parameter != null) {
					parameter.visit(visitor);
				}
			}
			for (CodeExpression arg : baseCtorArgs) {
				if (arg != null) {
					arg.visit(visitor);
				}
			}
			for (CodeExpression arg : chainedCtorArgs) {
				if (arg != null) {
					arg.visit(visitor);
				}
			}
			for (CodeStatement statement : getStatements()) {
				if (statement != null) {
					statement.visit(visitor);
				}
			}
		}
	}

	@Override
	public boolean equals(Object arg) {
		if (!(arg instanceof CodeConstructor)) {
			// includes null
			return false;
		}

		CodeConstructor that = (CodeConstructor)arg;

		int length = this.baseCtorArgs.size();
		if (length != that.baseCtorArgs.size()) {
			return false;
		}

		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy