net.sf.freecol.common.model
Class BuildQueue<T extends BuildableType>

java.lang.Object
  extended by net.sf.freecol.common.model.BuildQueue<T>
All Implemented Interfaces:
Consumer

public class BuildQueue<T extends BuildableType>
extends java.lang.Object
implements Consumer


Nested Class Summary
static class BuildQueue.CompletionAction
           
 
Field Summary
private  java.util.List<T> buildQueue
          A list of Buildable items.
private  Colony colony
           
private  BuildQueue.CompletionAction completionAction
          What to do when an item has been completed.
private  int priority
           
 
Fields inherited from interface net.sf.freecol.common.model.Consumer
BUILDING_PRIORITY, COLONY_PRIORITY, COMPARATOR, POPULATION_PRIORITY, UNIT_PRIORITY
 
Constructor Summary
BuildQueue(Colony colony, BuildQueue.CompletionAction action, int priority, T... items)
           
 
Method Summary
 void add(T buildable)
           
 void clear()
           
 boolean consumes(GoodsType goodsType)
          Returns true if this Consumer consumes the given GoodsType.
 BuildQueue.CompletionAction getCompletionAction()
          Get the CompletionAction value.
 java.util.List<AbstractGoods> getConsumedGoods()
          Returns a list of GoodsTypes this Consumer consumes.
 T getCurrentlyBuilding()
          Returns the type of building currently being built.
 java.util.Set<Modifier> getModifierSet(java.lang.String id)
          Returns the modifier set with the given id.
 int getPriority()
          The priority of this Consumer.
 ProductionInfo getProductionInfo(java.util.List<AbstractGoods> input)
          Return the ProductionInfo for this BuildQueue.
 java.util.List<T> getValues()
           
 boolean hasAbility(java.lang.String id)
          Returns whether the consumer has the ability with the given id.
 boolean isEmpty()
           
 void remove(int index)
           
 void setCompletionAction(BuildQueue.CompletionAction newCompletionAction)
          Set the CompletionAction value.
 void setCurrentlyBuilding(T buildable)
          Sets the current type of buildable to be built and if it is a building insist that there is only one in the queue.
 void setValues(java.util.List<T> values)
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buildQueue

private java.util.List<T extends BuildableType> buildQueue
A list of Buildable items.


completionAction

private BuildQueue.CompletionAction completionAction
What to do when an item has been completed.


priority

private int priority

colony

private Colony colony
Constructor Detail

BuildQueue

public BuildQueue(Colony colony,
                  BuildQueue.CompletionAction action,
                  int priority,
                  T... items)
Method Detail

getCurrentlyBuilding

public T getCurrentlyBuilding()
Returns the type of building currently being built.

Returns:
The type of building currently being built.

setCurrentlyBuilding

public void setCurrentlyBuilding(T buildable)
Sets the current type of buildable to be built and if it is a building insist that there is only one in the queue.

Parameters:
buildable - The T to build.

clear

public void clear()

add

public void add(T buildable)

getValues

public java.util.List<T> getValues()

setValues

public void setValues(java.util.List<T> values)

remove

public void remove(int index)

size

public int size()

isEmpty

public boolean isEmpty()

getCompletionAction

public final BuildQueue.CompletionAction getCompletionAction()
Get the CompletionAction value.

Returns:
a CompletionAction value

setCompletionAction

public final void setCompletionAction(BuildQueue.CompletionAction newCompletionAction)
Set the CompletionAction value.

Parameters:
newCompletionAction - The new CompletionAction value.

consumes

public boolean consumes(GoodsType goodsType)
Returns true if this Consumer consumes the given GoodsType.

Parameters:
goodsType - a GoodsType value
Returns:
a boolean value

getConsumedGoods

public java.util.List<AbstractGoods> getConsumedGoods()
Returns a list of GoodsTypes this Consumer consumes.

Specified by:
getConsumedGoods in interface Consumer
Returns:
a List value

getProductionInfo

public ProductionInfo getProductionInfo(java.util.List<AbstractGoods> input)
Return the ProductionInfo for this BuildQueue.

Parameters:
input - the goods available
Returns:
the ProductionInfo for this BuildQueue

getPriority

public int getPriority()
The priority of this Consumer. The higher the priority, the earlier will the Consumer be allowed to consume the goods it requires.

Specified by:
getPriority in interface Consumer
Returns:
an int value

hasAbility

public boolean hasAbility(java.lang.String id)
Returns whether the consumer has the ability with the given id. The two abilities most relevant to consumers are "consumeAllOrNothing", which implies that the consumer will not consume any goods if its requirements can not be met (used by the Colony when building), as well as "consumeOnlySurplusProduction", which implies that the consumer does not consume stored goods (used by the country and stables).

Specified by:
hasAbility in interface Consumer
Parameters:
id - a String value
Returns:
a boolean value

getModifierSet

public java.util.Set<Modifier> getModifierSet(java.lang.String id)
Returns the modifier set with the given id. The modifier most relevant to consumers is "consumeOnlySurplusProduction", which implies that the consumer does not consume stored goods (used by the country and stables).

Specified by:
getModifierSet in interface Consumer
Parameters:
id - a String value
Returns:
a boolean value

toString

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