Class WareHolding
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.impl.WareHolding
-
- Direct Known Subclasses:
City
,TradingOffice
public abstract class WareHolding extends java.lang.Object
This class represents an entity that can hold wares which can be moved- Author:
- Andi Hotz, (c) Sahits GmbH, 2011 Created on Dec 17, 2011
-
-
Field Summary
Fields Modifier and Type Field Description private AmountableProvider
amountableProvider
protected ComputablePriceV2
computablePrice
private javafx.beans.property.IntegerProperty
occupiedSpace
Space occupied by some tenantprivate LateIntegerBinding
storedAmountBinding
Binding representing the current load.(package private) NonReplacableMap<IWare,AmountablePrice<IWare>>
wares
Store the amount of wares in the city in the ware specific sizes
-
Constructor Summary
Constructors Constructor Description WareHolding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addNewWare(IWare ware, int amount)
Add a new ware to the wares listprotected void
bindStoredAmount(javafx.beans.property.ReadOnlyIntegerProperty amountProperty)
Bind theamountProperty
.protected int
computeAVGPrice(IWare ware, int amount)
Compute the average price for ware that is to be purchased in the specified amount.protected boolean
containsWare(IWare ware)
Check if there is an amountable object for this wareint
getOccupiedSpace()
AmountablePrice<IWare>
getWare(IWare ware)
Retrieve theAmountablePrice
of the ware as it is stored in the holdingprivate int
internalStoredAmountCalculation()
Calculate the stored amount.int
move(IWare ware, int amount, ICitizen player)
Move ware into this holding.javafx.beans.property.IntegerProperty
occupiedSpaceProperty()
void
setOccupiedSpace(int occupiedSpace)
LateIntegerBinding
storedAmountBinding()
protected void
unbindAllAmounts()
Unbind all bound amounts.
-
-
-
Field Detail
-
wares
final NonReplacableMap<IWare,AmountablePrice<IWare>> wares
Store the amount of wares in the city in the ware specific sizes
-
occupiedSpace
private final javafx.beans.property.IntegerProperty occupiedSpace
Space occupied by some tenant
-
computablePrice
@Autowired protected ComputablePriceV2 computablePrice
-
amountableProvider
@Autowired private AmountableProvider amountableProvider
-
storedAmountBinding
private LateIntegerBinding storedAmountBinding
Binding representing the current load.
-
-
Method Detail
-
addNewWare
protected void addNewWare(IWare ware, int amount)
Add a new ware to the wares list- Parameters:
ware
- to be addedamount
- ofware
to be added.
-
bindStoredAmount
protected void bindStoredAmount(javafx.beans.property.ReadOnlyIntegerProperty amountProperty)
Bind theamountProperty
.- Parameters:
amountProperty
- to be bound.
-
unbindAllAmounts
protected void unbindAllAmounts()
Unbind all bound amounts.
-
getWare
public AmountablePrice<IWare> getWare(IWare ware)
Retrieve theAmountablePrice
of the ware as it is stored in the holding- Parameters:
ware
- to be retrieved- Returns:
- AmountablePrice object
-
move
public int move(IWare ware, int amount, ICitizen player)
Move ware into this holding. The player may be null and is not used in this base implementation, but subclasses may be interested for statistical reasons. This method is thread save.- Parameters:
ware
- to be movedamount
- of the ware that is movedplayer
- that initiates the moving, may be null, e.g. if the moving is initiated by a city- Returns:
- the effective amount that was moved. The amount may be positive if something was added, negative if the ware was removed from the holding or zero if nothing was moved.
-
containsWare
protected final boolean containsWare(IWare ware)
Check if there is an amountable object for this ware- Parameters:
ware
- to be checked for containemnt- Returns:
- true if the ware is present in the WareHolding.
-
computeAVGPrice
protected int computeAVGPrice(IWare ware, int amount)
Compute the average price for ware that is to be purchased in the specified amount. The additional variable of the available amount is supplied bygetWare(IWare)
. Subclasses may override this method.- Parameters:
ware
- for which the average price is to be computedamount
- amount that is bought- Returns:
- average price for the
amount
ofware
.
-
internalStoredAmountCalculation
private int internalStoredAmountCalculation()
Calculate the stored amount.- Returns:
- total amount of stored wares.
-
storedAmountBinding
public LateIntegerBinding storedAmountBinding()
-
occupiedSpaceProperty
public javafx.beans.property.IntegerProperty occupiedSpaceProperty()
-
getOccupiedSpace
public int getOccupiedSpace()
-
setOccupiedSpace
public void setOccupiedSpace(int occupiedSpace)
-
-