Skip to content

Commit

Permalink
Added files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
afbarbaro committed Apr 5, 2016
1 parent 6df4782 commit 4e77615
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/examples/portfolio/PortfolioAssetInterface.java
Original file line number Diff line number Diff line change
@@ -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);
}
26 changes: 26 additions & 0 deletions src/test/java/examples/portfolio/PortfolioValueAccumulator.java
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 4e77615

Please sign in to comment.