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

org.duelengine.duel.codedom.CodeObjectCreateExpression 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.Arrays;
import java.util.List;

/**
 * Represents a constructor call
 */
public class CodeObjectCreateExpression extends CodeExpression {

	private String typeName;
	private final List arguments = new ArrayList();

	public CodeObjectCreateExpression() {
	}

	public CodeObjectCreateExpression(String typeName, CodeExpression... args) {
		this.typeName = typeName;
		if (args != null) {
			this.arguments.addAll(Arrays.asList(args));
		}
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String value) {
		typeName = value;
	}

	public List getArguments() {
		return arguments;
	}

	@Override
	public Class getResultType() {
		return Object.class;
	}

	@Override
	public void visit(CodeVisitor visitor) {
		if (visitor.visit(this)) {
			for (CodeExpression expression : arguments) {
				if (expression != null) {
					expression.visit(visitor);
				}
			}
		}
	}

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

		CodeObjectCreateExpression that = (CodeObjectCreateExpression)arg;

		if (this.typeName == null ? that.typeName != null : !this.typeName.equals(that.typeName)) {
			return false;
		}

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

		for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy