Package net.sf.freecol.common.model
Class BuildQueue<T extends BuildableType>
- java.lang.Object
-
- net.sf.freecol.common.model.BuildQueue<T>
-
- All Implemented Interfaces:
Consumer
public class BuildQueue<T extends BuildableType> extends java.lang.Object implements Consumer
A queue of things for a colony to build.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBuildQueue.CompletionAction
-
Field Summary
Fields Modifier and Type Field Description private ColonycolonyThe colony to queue buildables for.private BuildQueue.CompletionActioncompletionActionWhat to do when an item has been completed.private intpriorityThe build priority.private java.util.List<T>queueA list of Buildable items.-
Fields inherited from interface net.sf.freecol.common.model.Consumer
BUILDING_PRIORITY, COLONY_PRIORITY, COMPARATOR, POPULATION_PRIORITY, UNIT_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description BuildQueue(Colony colony, BuildQueue.CompletionAction action, int priority)Create a new build queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T buildable)voidclear()BuildQueue.CompletionActiongetCompletionAction()java.util.List<AbstractGoods>getConsumedGoods()Returns a list of GoodsTypes this Consumer consumes.java.util.stream.Stream<Modifier>getConsumptionModifiers(java.lang.String id)Get the modifier set with the given id.TgetCurrentlyBuilding()Get the type of building currently being built.intgetPriority()The priority of this Consumer.ProductionInfogetProductionInfo(java.util.List<AbstractGoods> input)Get theProductionInfofor this BuildQueue.java.util.List<T>getValues()booleanisEmpty()voidremove(int index)voidsetCompletionAction(BuildQueue.CompletionAction newCompletionAction)voidsetCurrentlyBuilding(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.voidsetValues(java.util.List<T> values)intsize()java.lang.StringtoString()
-
-
-
Field Detail
-
queue
private final java.util.List<T extends BuildableType> queue
A list of Buildable items.
-
completionAction
private BuildQueue.CompletionAction completionAction
What to do when an item has been completed.
-
priority
private int priority
The build priority.
-
colony
private final Colony colony
The colony to queue buildables for.
-
-
Constructor Detail
-
BuildQueue
public BuildQueue(Colony colony, BuildQueue.CompletionAction action, int priority)
Create a new build queue.- Parameters:
colony- TheColonyto build for.action- The action on build completion.priority- The build priority.
-
-
Method Detail
-
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()
-
setCompletionAction
public final void setCompletionAction(BuildQueue.CompletionAction newCompletionAction)
-
getCurrentlyBuilding
public T getCurrentlyBuilding()
Get 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- TheTto build.
-
getProductionInfo
public ProductionInfo getProductionInfo(java.util.List<AbstractGoods> input)
Get theProductionInfofor this BuildQueue.- Parameters:
input- A list of inputAbstractGoods.- Returns:
- The
ProductionInfofor this BuildQueue.
-
getConsumedGoods
public java.util.List<AbstractGoods> getConsumedGoods()
Returns a list of GoodsTypes this Consumer consumes.- Specified by:
getConsumedGoodsin interfaceConsumer- Returns:
- a
Listvalue
-
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:
getPriorityin interfaceConsumer- Returns:
- an
intvalue
-
getConsumptionModifiers
public java.util.stream.Stream<Modifier> getConsumptionModifiers(java.lang.String id)
Get 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:
getConsumptionModifiersin interfaceConsumer- Parameters:
id- The object identifier.- Returns:
- The stream of
Modifiers found.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-