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

org.overture.pof.AVdmPoTree Maven / Gradle / Ivy

/*******************************************************************************
* Copyright (c) 2009, 2011 Overture Team and others.
*
* Overture is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Overture is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Overture.  If not, see .
*
* The Overture Tool web-site: http://overturetool.org/
*******************************************************************************/

/* This file was generated by ASTcreator (http://www.lausdahl.com/). */

package org.overture.pof;


import org.overture.pof.AVdmPoTree;
import org.overture.ast.expressions.PExp;
import java.util.Map;
import org.overture.pof.analysis.intf.IPOFAnalysis;
import java.lang.Boolean;
import org.overture.pof.analysis.intf.IPOFAnswer;
import java.lang.String;
import org.overture.pof.analysis.intf.IPOFQuestion;
import java.util.HashMap;
import org.overture.pof.analysis.intf.IPOFQuestionAnswer;
import org.overture.ast.analysis.intf.IAnalysis;
import org.overture.ast.analysis.intf.IQuestionAnswer;
import org.overture.ast.node.INode;
import org.overture.ast.analysis.intf.IAnswer;
import org.overture.ast.analysis.intf.IQuestion;
import org.overture.ast.analysis.AnalysisException;
import org.overture.pof.PPoTreeBase;


/**
* Generated file by AST Creator
* @author Kenneth Lausdahl
*
* Extensions by the COMPASS Project
* @author Rasmus Winther Lauritsen, Anders Kaels Malmos
*
*/
public class AVdmPoTree extends PPoTreeBase
{
	private static final long serialVersionUID = 1L;

	private PExp _predicate;

	/**
	 * Creates a new {@link AVdmPoTree} node with no children.
	 */
	public AVdmPoTree()
	{

	}



	/**
	* Creates a new {@code AVdmPoTree} node with the given nodes as children.
	* @deprecated This method should not be used, use AstFactory instead.
	* The basic child nodes are removed from their previous parents.
	* @param predicate_ the {@link PExp} node for the {@code predicate} child of this {@link AVdmPoTree} node
	*/
	public AVdmPoTree(PExp predicate_)
	{
		super();
		this.setPredicate(predicate_);

	}


	/**
	 * Creates a deep clone of this {@link AVdmPoTree} node while putting all
	 * old node-new node relations in the map {@code oldToNewMap}.
	 * @param oldToNewMap the map filled with the old node-new node relation
	 * @return a deep clone of this {@link AVdmPoTree} node
	 */
	public AVdmPoTree clone(Map oldToNewMap)
	{
		AVdmPoTree node = new AVdmPoTree(
			cloneNode(_predicate, oldToNewMap)
		);
		oldToNewMap.put(this, node);
		return node;
	}


	/**
	 * Returns a deep clone of this {@link AVdmPoTree} node.
	 * @return a deep clone of this {@link AVdmPoTree} node
	 */
	public AVdmPoTree clone()
	{
		return new AVdmPoTree(
			cloneNode(_predicate)
		);
	}


	/**
	* Essentially this.toString().equals(o.toString()).
	**/
	@Override
	public boolean equals(Object o)
	{
		if (o != null && o instanceof AVdmPoTree)		{
			 return toString().equals(o.toString());
		}
		return false;
	}



	public String toString()
	{
		return "" + ""+_predicate;
	}


	/**
	 * Creates a map of all field names and their value
	 * @param includeInheritedFields if true all inherited fields are included
	 * @return a a map of names to values of all fields
	 */
	@Override
	public Map getChildren(Boolean includeInheritedFields)
	{
		Map fields = new HashMap();
		if(includeInheritedFields)
		{
			fields.putAll(super.getChildren(includeInheritedFields));
		}
		fields.put("_predicate",this._predicate);
		return fields;
	}


	/**
	 * Removes the {@link INode} {@code child} as a child of this {@link AVdmPoTree} node.
	 * Do not call this method with any graph fields of this node. This will cause any child's
	 * with the same reference to be removed unintentionally or {@link RuntimeException}will be thrown.
	 * @param child the child node to be removed from this {@link AVdmPoTree} node
	 * @throws RuntimeException if {@code child} is not a child of this {@link AVdmPoTree} node
	 */
	public void removeChild(INode child)
	{
		if (this._predicate == child) {
			this._predicate = null;
			return;
		}

		throw new RuntimeException("Not a child.");
	}


	/**
	* Forwarding hashCode call to {@link Object#hashCode()}.
	**/
	@Override
	public int hashCode()
	{
		return super.hashCode();
	}


	/**
	 * Sets the {@code _predicate} child of this {@link AVdmPoTree} node.
	 * @param value the new {@code _predicate} child of this {@link AVdmPoTree} node
	*/
	public void setPredicate(PExp value)
	{
		if (this._predicate != null) {
			this._predicate.parent(null);
		}
		if (value != null) {
			if (value.parent() != null) {
				value.parent().removeChild(value);
		}
			value.parent(this);
		}
		this._predicate = value;

	}


	/**
	 * @return the {@link PExp} node which is the {@code _predicate} child of this {@link AVdmPoTree} node
	*/
	public PExp getPredicate()
	{
		return this._predicate;
	}


	/**
	* Calls the {@link IAnalysis#caseAVdmPoTree(AVdmPoTree)} of the {@link IAnalysis} {@code caller}.
	* @param caller the {@link IAnalysis} to which this {@link AVdmPoTree} node is applied
	*/
	@Override
	public void apply(IAnalysis caller) throws AnalysisException
	{
		if(caller instanceof IPOFAnalysis)
		{
			((IPOFAnalysis)caller).caseAVdmPoTree(this);
		}else
		{
			caller.defaultINode(this);
		}
	}


	/**
	* Calls the {@link IAnswer#caseAVdmPoTree(AVdmPoTree)} of the {@link IAnswer} {@code caller}.
	* @param caller the {@link IAnswer} to which this {@link AVdmPoTree} node is applied
	*/
	@SuppressWarnings("unchecked")
	@Override
	public  A apply(IAnswer caller) throws AnalysisException
	{
		if(caller instanceof IPOFAnswer)
		{
			return (A)((IPOFAnswer)caller).caseAVdmPoTree(this);
		}else
		{
			return caller.defaultINode(this);
		}
	}


	/**
	* Calls the {@link IQuestion#caseAVdmPoTree(AVdmPoTree, Object)} of the {@link IQuestion} {@code caller}.
	* @param caller the {@link IQuestion} to which this {@link AVdmPoTree} node is applied
	* @param question the question provided to {@code caller}
	*/
	@SuppressWarnings("unchecked")
	@Override
	public  void apply(IQuestion caller, Q question) throws AnalysisException
	{
		if(caller instanceof IPOFQuestion)
		{
			((IPOFQuestion)caller).caseAVdmPoTree(this, question);
		}else
		{
			caller.defaultINode(this,question);
		}
	}


	/**
	* Calls the {@link IQuestionAnswer#caseAVdmPoTree(AVdmPoTree, Object)} of the {@link IQuestionAnswer} {@code caller}.
	* @param caller the {@link IQuestionAnswer} to which this {@link AVdmPoTree} node is applied
	* @param question the question provided to {@code caller}
	*/
	@SuppressWarnings("unchecked")
	@Override
	public  A apply(IQuestionAnswer caller, Q question) throws AnalysisException
	{
		if(caller instanceof IPOFQuestionAnswer)
		{
			return (A)((IPOFQuestionAnswer)caller).caseAVdmPoTree(this, question);
		}else
		{
			return caller.defaultINode(this,question);
		}
	}



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy