mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Added files via upload
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package examples.portfolio;
|
||||
|
||||
public interface PortfolioAssetInterface
|
||||
{
|
||||
public long getAssetId();
|
||||
public void setAssetId(long assetId);
|
||||
|
||||
public int getShares();
|
||||
public void setShares(int shares);
|
||||
|
||||
public double getPrice();
|
||||
public void setPrice(double price);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package examples.portfolio;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableDouble;
|
||||
|
||||
import net.openhft.chronicle.core.values.LongValue;
|
||||
import net.openhft.chronicle.map.MapEntry;
|
||||
|
||||
public final class PortfolioValueAccumulator implements Consumer<MapEntry<LongValue, PortfolioAssetInterface>>
|
||||
{
|
||||
final MutableDouble total;
|
||||
final PortfolioAssetInterface asset;
|
||||
public PortfolioValueAccumulator(MutableDouble total, PortfolioAssetInterface asset)
|
||||
{
|
||||
this.total = total;
|
||||
this.asset = asset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(MapEntry<LongValue, PortfolioAssetInterface> e)
|
||||
{
|
||||
e.value().getUsing(asset);
|
||||
total.add(asset.getShares() * asset.getPrice());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user