package com.eactive.eai.transformer.function;

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

import com.eactive.eai.transformer.dao.LoadingUnit;

public class FunctionDefinition extends LoadingUnit {
	private static final long serialVersionUID = 1L;

	private String name;
	private String description;
	private int returnTypeId;
	private int functionTypeId;
	private String functionClass;
	private List<ParameterDefinition> parameterList;

	public FunctionDefinition() {
		parameterList = new ArrayList<>();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getReturnTypeId() {
		return returnTypeId;
	}

	public void setReturnTypeId(int returnTypeId) {
		this.returnTypeId = returnTypeId;
	}

	public int getFunctionTypeId() {
		return functionTypeId;
	}

	public void setFunctionTypeId(int functionTypeId) {
		this.functionTypeId = functionTypeId;
	}

	public String getFunctionClass() {
		return functionClass;
	}

	public void setFunctionClass(String functionClass) {
		this.functionClass = functionClass;
	}

	public List<ParameterDefinition> getParameterList() {
		return parameterList;
	}

	public void addParameter(ParameterDefinition parameter) {
		parameterList.add(parameter);
	}

	public int getParameterCount() {
		return parameterList.size();
	}

	public ParameterDefinition getParameter(int index) {
		return parameterList.get(index);
	}

	public ParameterDefinition removeParameter(int index) {
		return parameterList.remove(index);
	}

	public void setParameterList(List<ParameterDefinition> parameterList) {
		this.parameterList = parameterList;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("FunctionDefinition[ name=").append(name);
		sb.append(", description=").append(description);
		sb.append(", returnTypeId=").append(returnTypeId);
		sb.append(", functionTypeId=").append(functionTypeId);
		sb.append(", functionClass=").append(functionClass);
		sb.append(", parameterList=").append(parameterList);
		sb.append(" ]");

		return sb.toString();
	}
}
