public class BidCache
extends java.lang.Object
BidCache
is an object that makes it easy to store bids received from agents and aggregate them into an
AggregatedBid
. This also stores all the generated AggregatedBid
s such that they can easily be
recalled later.
This class is thread-safe.Constructor and Description |
---|
BidCache(MarketBasis marketBasis)
Creates a new
BidCache based on the MarketBasis . |
Modifier and Type | Method and Description |
---|---|
AggregatedBid |
aggregate()
Creates a new
AggregatedBid based on the current cache bids. |
void |
removeBidOfAgent(java.lang.String agentId)
Removed the bid of the agent from this cache.
|
void |
updateAgentBid(java.lang.String agentId,
BidUpdate bid)
Updates the bid for a specific agent identifier.
|
public BidCache(MarketBasis marketBasis)
BidCache
based on the MarketBasis
.marketBasis
- The MarketBasis
that is used to match the bids.public void updateAgentBid(java.lang.String agentId, BidUpdate bid)
agentId
- The unique identifier of the agent. See Agent.getAgentId()
.bid
- The BidUpdate
that the agent has sent and has to be cache here. When the bid is
null
, the reference will be removed completely (effectively the same as calling
removeBidOfAgent(String)
).java.lang.IllegalArgumentException
- When the marketBasis of the bid does not match the marketBasis on which this BidCache
is
based.public void removeBidOfAgent(java.lang.String agentId)
agentId
- The unique identifier of the agent. See Agent.getAgentId()
.public AggregatedBid aggregate()
AggregatedBid
based on the current cache bids. This adds up all the bids and saves the
references to the agent bids.AggregatedBid
.