org.argkit.dung
Class Branch<C>

java.lang.Object
  extended by org.argkit.dung.Branch<C>
Type Parameters:
C - (Argument's) claim class

public class Branch<C>
extends java.lang.Object

A class that it used to store a branch of a particular argument game dialogue.

Author:
Matt South

Constructor Summary
Branch()
          Default constructor.
Branch(Argument<C> proArg)
          Typical constructor.
 
Method Summary
 void addOPP(Argument<C> argument)
          Add an OPP argument to this branch.
 void addPRO(Argument<C> argument)
          Add a PRO argument to this branch.
 Branch<C> copy()
          Make a copy of this Branch.
 Argument<C> getLastArgument()
           
 boolean isProWinning()
           
 java.util.Iterator<Argument<C>> iterator()
          Note that there is no explicit markup of PRO/OPP ownership of arguments, this is left for the consumer to work out, knowing that the first argument yielded will be a PRO argument, and all arguments thereafter will swap between OPP and PRO.
 java.util.Set<Argument<C>> oppArguments()
           
 java.util.Iterator<Argument<C>> oppIterator()
           
 java.util.Set<Argument<C>> proArguments()
           
 java.util.Iterator<Argument<C>> proIterator()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Branch

public Branch()
Default constructor. Next argument added must be a PRO argument.


Branch

public Branch(Argument<C> proArg)
Typical constructor. Next argument added must be an OPP argument.

Parameters:
proArg -
Method Detail

addPRO

public void addPRO(Argument<C> argument)
Add a PRO argument to this branch. If the previous argument added to this branch was a PRO argument, then a InvalidParameterException will be thrown.

Parameters:
argument - the PRO argument to be added to the branch

addOPP

public void addOPP(Argument<C> argument)
Add an OPP argument to this branch. If the previous argument added to this branch was a OPP argument, then a InvalidParameterException will be thrown.

Parameters:
argument - the OPP argument to be added to the branch

getLastArgument

public Argument<C> getLastArgument()
Returns:
the last argument made in this branch.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isProWinning

public boolean isProWinning()
Returns:
true if PRO has the last argument.

iterator

public java.util.Iterator<Argument<C>> iterator()
Note that there is no explicit markup of PRO/OPP ownership of arguments, this is left for the consumer to work out, knowing that the first argument yielded will be a PRO argument, and all arguments thereafter will swap between OPP and PRO.

Returns:
an iterator over the branch's arguments.

proIterator

public java.util.Iterator<Argument<C>> proIterator()
Returns:
an iterator over all of PRO's arguments

oppIterator

public java.util.Iterator<Argument<C>> oppIterator()
Returns:
an iterator over all of OPP's arguments

proArguments

public java.util.Set<Argument<C>> proArguments()
Returns:
a set containing all of PRO's arguments.

oppArguments

public java.util.Set<Argument<C>> oppArguments()
Returns:
a set containing all of OPP's arguments.

copy

public Branch<C> copy()
Make a copy of this Branch. The composite lists pro and opp are new, but their contents are not (i.e they use the same references).

Returns:
a copy of this Branch.