/** * Thread class */ package onetomany.bargainingchipsgame.interactions; import java.util.List; //import onetomany.etc; didn't work! import onetomany.bargainingchipsgame.Bundle; import onetomany.bargainingchipsgame.players.Agent; import onetomany.etc.OtherOperators; /** * Thread is a for a bilateral negotiation. * It is defined by introducing two parties and a list of actions exchanging between the two. * * * @author Faria Nassiri-Mofakham * */ public class Thread { private List actions; private Agent agent1; private Agent agent2; private long deadline; // is it required that a thread to have a deadline ?! When any party would send an end, so it will issue closing operation on the thread. So, we may only need to know when a thread were concluded. right? private Boolean valid; private Bundle outcome; public Thread() { setActions(null); setAgent1(null); setAgent2(null); setDeadline(0); setValid(Boolean.FALSE); setOutcome(null); } public Thread(Agent g1, Agent g2) { setActions(null); setAgent1(g1); setAgent2(g2); setDeadline(Math.min(g1.getDeadline(),g2.getDeadline())); setValid(Boolean.FALSE); setOutcome(null); } public void addAction(Action c) { actions.add(c); } @Override public String toString() { return " Bilateral thred "+this.getClass().getSimpleName()+"\n within deadline "+this.getDeadline()+"\n between "+this.getAgent1()+"\n and \n"+this.getAgent1()+"\n through the following actions \n "+this.getActions(); } /** * @ At the time of closing the thread, checks the sequence of actions to see if the thread is valid the valid to set */ public void setValid(Boolean b) { // for (Action c : this.actions) // if this.valid = b; } /** * @return the actions */ public List getActions() { return actions; } /** * @param actions the actions to set */ public void setActions(List actions) { this.actions = actions; } /** * @return the agent1 */ public Agent getAgent1() { return agent1; } /** * @param agent1 the agent1 to set */ public void setAgent1(Agent agent1) { this.agent1 = agent1; } /** * @return the agent2 */ public Agent getAgent2() { return agent2; } /** * @param agent2 the agent2 to set */ public void setAgent2(Agent agent2) { this.agent2 = agent2; } /** * @return the deadline */ public long getDeadline() { return deadline; } /** * @param deadline the deadline to set */ public void setDeadline(long deadline) { this.deadline = deadline; } /** * @return the valid */ public Boolean getValid() { return valid; } /** * @return the outcome */ public Bundle getOutcome() { return outcome; } /** * @param outcome the outcome to set */ public void setOutcome(Bundle outcome) { this.outcome = outcome; } }