jadex.bdi.model.MTrigger Maven / Gradle / Ivy
The newest version!
package jadex.bdi.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jadex.common.UnparsedExpression;
/**
* Model element for a plan trigger.
*/
public class MTrigger
{
/** The message events. */
protected List messageevents;
/** The goal types. */
protected List goals;
/** Goal match expressions that restrict general goal type triggers. */
protected Map goalmatches;
/** The goal types of finished goals. */
protected List goalfinisheds;
/** The belief names. */
protected List factaddeds;
/** The belief names. */
protected List factremoveds;
/** The belief names. */
protected List factchangeds;
/** The service types. */
protected List services;
//-------- additional xml properties --------
// hack!!! required for two pass reading.
protected List messagenames;
protected List ieventnames;
protected List goalnames;
protected List goalfinishednames;
protected Map goalmatchnames;
/** The trigger condition. */
protected MCondition condition;
/**
* Create a new trigger.
*/
public MTrigger()
{
}
/**
* Get the message events.
*/
public List getMessageEvents()
{
return messageevents;
}
/**
* Get the goals.
*/
public List getGoals()
{
return goals;
}
/**
* Set the goals.
* @param goals The goals to set
*/
public void setGoals(List goals)
{
this.goals = goals;
}
/**
* Add a goal trigger.
*/
public void addGoal(MGoal goal)
{
if(goals==null)
this.goals = new ArrayList();
goals.add(goal);
}
/**
* Get the goalfinisheds.
* @return The goalfinisheds.
*/
public List getGoalFinisheds()
{
return goalfinisheds;
}
/**
* Add a goal finished trigger.
*/
public void addGoalFinished(MGoal goal)
{
if(goalfinisheds==null)
this.goalfinisheds = new ArrayList();
goalfinisheds.add(goal);
}
/**
* Add a message event.
*/
public void addMessageEvent(MMessageEvent event)
{
if(messageevents==null)
this.messageevents = new ArrayList();
messageevents.add(event);
}
/**
* Add a message event name.
*/
public void addMessageName(String event)
{
if(messagenames==null)
this.messagenames = new ArrayList();
messagenames.add(event);
}
/**
* Get the message events.
*/
public List getMessageNames()
{
return messagenames;
}
/**
* Add an internal event name.
*/
public void addInternalEventName(String event)
{
if(ieventnames==null)
this.ieventnames = new ArrayList();
ieventnames.add(event);
}
/**
* Get the message events.
*/
public List getInternalEventNames()
{
return ieventnames;
}
/**
* Add a goal finished name.
*/
public void addGoalFinishedName(String event)
{
if(goalfinishednames==null)
this.goalfinishednames = new ArrayList();
goalfinishednames.add(event);
}
/**
* Get the goal finished events.
*/
public List getGoalFinishedNames()
{
return goalfinishednames;
}
/**
* Add a goal name.
*/
public void addGoalName(String event)
{
if(goalnames==null)
this.goalnames = new ArrayList();
goalnames.add(event);
}
/**
* Get the goal events.
*/
public List getGoalNames()
{
return goalnames;
}
/**
* Set the goalnames.
* @param goalnames The goalnames to set
*/
public void setGoalNames(List goalnames)
{
this.goalnames = goalnames;
}
/**
* Add a goal match before preprecessing (i.e. unresolved name).
*/
public void addGoalNameMatchExpression(String goalname, UnparsedExpression match)
{
if(goalmatchnames==null)
this.goalmatchnames = new HashMap();
goalmatchnames.put(goalname, match);
}
/**
* Get goal match expressions for preprecessing.
*/
public Map getGoalNameMatchExpressions()
{
return goalmatchnames;
}
/**
* Add a goal name.
*/
public void addGoalMatchExpression(String goalname, UnparsedExpression match)
{
if(goalmatches==null)
this.goalmatches = new HashMap();
goalmatches.put(goalname, match);
}
/**
* Get a goal match expression.
*/
public UnparsedExpression getGoalMatchExpression(MGoal mgoal)
{
return goalmatches==null? null: goalmatches.get(mgoal.getName());
}
// /**
// * Get the goal finished events.
// */
// public IMTriggerReference[] getGoalFinisheds();
/**
* Add a fact added belief trigger.
*/
public void addFactAdded(String fact)
{
if(factaddeds==null)
this.factaddeds = new ArrayList();
factaddeds.add(fact);
}
/**
* Add a fact removed belief trigger.
*/
public void addFactRemoved(String fact)
{
if(factremoveds==null)
this.factremoveds = new ArrayList();
factremoveds.add(fact);
}
/**
* Add a fact changed belief trigger.
*/
public void addFactChanged(String fact)
{
if(factchangeds==null)
this.factchangeds = new ArrayList();
factchangeds.add(fact);
}
/**
* Get the fact added triggers (belief set names).
*/
public List getFactAddeds()
{
return factaddeds==null? Collections.emptyList(): factaddeds;
}
/**
* Get the fact removed triggers (belief set names).
*/
public List getFactRemoveds()
{
return factremoveds==null? Collections.emptyList(): factremoveds;
}
/**
* Get the fact changeds triggers (belief set names).
*/
public List getFactChangeds()
{
return factchangeds==null? Collections.emptyList(): factchangeds;
}
/**
* Set the fact added triggers (belief set names).
*/
public void setFactAddeds(List events)
{
this.factaddeds = events;
}
/**
* Set the fact removed triggers (belief set names).
*/
public void setFactRemoveds(List events)
{
this.factremoveds = events;
}
/**
* Set the fact changeds triggers (belief set names).
*/
public void setFactChangeds(List events)
{
this.factchangeds = events;
}
/**
* Add a service trigger.
*/
public void addService(MServiceCall service)
{
if(services==null)
this.services = new ArrayList();
services.add(service);
}
/**
* Get the fact service calls.
*/
public List getServices()
{
return services==null? Collections.emptyList(): services;
}
/**
* Get the condition.
*/
public MCondition getCondition()
{
return condition;
}
/**
* Set the condition.
*/
public void setCondition(MCondition condition)
{
this.condition = condition;
}
}