org.duelengine.duel.codedom.CodeConstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of duel-compiler Show documentation
Show all versions of duel-compiler Show documentation
Dual-side template engine for the JVM
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