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

org.jamesii.ml3.parser.nodes.ProcedureDeclarationNode Maven / Gradle / Ivy

Go to download

The Modeling Language for Linked Lives, a domain specific modeling language for agent-based computational demography.

There is a newer version: 0.2.8
Show newest version
/*
 * Copyright 2017 University of Rostock
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jamesii.ml3.parser.nodes;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.jamesii.ml3.parser.AbstractParseTreeNode;
import org.jamesii.ml3.parser.nodes.statements.IStatement;

public class ProcedureDeclarationNode extends AbstractParseTreeNode {
	private String agentType;
	private String procedureName;
	private List parameters;
	private IStatement statement;
	private WhereClauseNode whereClause;

	public ProcedureDeclarationNode(ModelNode modelNode, String agentType, String procedureName) {
		super(modelNode);

		this.agentType = agentType;
		this.procedureName = procedureName;
		this.parameters = new ArrayList<>();
	}

	@Override
	public String toString() {
		// return "funcDec{" + whereClause + ":" + functionExpression + ":" +
		// parameterDeclarations + ":" + functionIdentifier + ":" +
		// agentIdentifier + "}";
		String params = String.join(", ",
				parameters.stream().map(e -> e.toString()).collect(Collectors.toList()));
		String where = (whereClause != null) ? "\n" + whereClause : "";
		return agentType + "." + procedureName + "(" + params + ")" + " -> " + statement + where + ";\n\n";
	}

	/**
	 * @return the agentType
	 */
	public String getAgentType() {
		return agentType;
	}

	/**
	 * @param agentType the agentType to set
	 */
	public void setAgentType(String agentType) {
		this.agentType = agentType;
	}

	/**
	 * @return the procedureName
	 */
	public String getProcedureName() {
		return procedureName;
	}

	/**
	 * @param procedureName the procedureName to set
	 */
	public void setProcedureName(String procedureName) {
		this.procedureName = procedureName;
	}

	/**
	 * @return the statement
	 */
	public IStatement getStatement() {
		return statement;
	}

	/**
	 * @param statement the statement to set
	 */
	public void setStatement(IStatement statement) {
		this.statement = statement;
	}

	/**
	 * @return the whereClause
	 */
	public WhereClauseNode getWhereClause() {
		return whereClause;
	}

	/**
	 * @param whereClause the whereClause to set
	 */
	public void setWhereClause(WhereClauseNode whereClause) {
		this.whereClause = whereClause;
	}

	/**
	 * @return the parameters
	 */
	public List getParameters() {
		return parameters;
	}
	
	public void addParameter(ParameterDeclarationNode parameter) {
		parameters.add(parameter);
	}

	/**
	 * @param parameters the parameters to set
	 */
	public void setParameters(List parameters) {
		this.parameters = parameters;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy