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 class
BuildQueue.CompletionAction
-
Field Summary
Fields Modifier and Type Field Description private Colony
colony
The colony to queue buildables for.private BuildQueue.CompletionAction
completionAction
What to do when an item has been completed.private int
priority
The build priority.private java.util.List<T>
queue
A 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 void
add(T buildable)
void
clear()
BuildQueue.CompletionAction
getCompletionAction()
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.T
getCurrentlyBuilding()
Get the type of building currently being built.int
getPriority()
The priority of this Consumer.ProductionInfo
getProductionInfo(java.util.List<AbstractGoods> input)
Get theProductionInfo
for this BuildQueue.java.util.List<T>
getValues()
boolean
isEmpty()
void
remove(int index)
void
setCompletionAction(BuildQueue.CompletionAction newCompletionAction)
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()
-
-
-
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
- TheColony
to 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
- TheT
to build.
-
getProductionInfo
public ProductionInfo getProductionInfo(java.util.List<AbstractGoods> input)
Get theProductionInfo
for this BuildQueue.- Parameters:
input
- A list of inputAbstractGoods
.- Returns:
- The
ProductionInfo
for this BuildQueue.
-
getConsumedGoods
public java.util.List<AbstractGoods> getConsumedGoods()
Returns a list of GoodsTypes this Consumer consumes.- Specified by:
getConsumedGoods
in interfaceConsumer
- Returns:
- a
List
value
-
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 interfaceConsumer
- Returns:
- an
int
value
-
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:
getConsumptionModifiers
in interfaceConsumer
- Parameters:
id
- The object identifier.- Returns:
- The stream of
Modifier
s found.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-