public final class Portfolio extends Object
Stock
objects,
in which the user has an interest in monitoring.
Methods in this class which take a Collection of Quote
objects as a parameter
Here is an example illustrating how to change the stocks contained in the portfolio :
fWorkingCopy = new TreeSet(fCurrentPortfolio.getStocks()); //..edit the contents of fWorkingCopy fCurrentPortfolio.setStocks(fWorkingCopy);Note that edits to fWorkingCopy can be easily abandoned, without affecting fCurrentPortfolio.
Constructor and Description |
---|
Portfolio(String aName,
Set<Stock> aStocks)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object aThat) |
BigDecimal |
getBookValue(Collection<Quote> aQuotes)
Return the cost of acquisition of all items in thisPortfolio which
also appear in aQuotes.
|
BigDecimal |
getCurrentValue(Collection<Quote> aQuotes)
Return the current worth of all items in the Portfolio which
also appear in aQuotes.
|
String |
getName()
Return the unique name of this Portfolio.
|
BigDecimal |
getPercentageProfit(Collection<Quote> aQuotes)
Return
getProfit(java.util.Collection<hirondelle.stocks.quotes.Quote>) divided by getBookValue(java.util.Collection<hirondelle.stocks.quotes.Quote>) ; if the book value
is zero, then return zero. |
BigDecimal |
getProfit(Collection<Quote> aQuotes)
|
List<Quote> |
getQuotes()
Return
Quote objects, one for each Stock in this
Portfolio. |
Set<Stock> |
getStocks()
Return the
Stock objects contained in this Portfolio. |
static Portfolio |
getUntitledPortfolio()
Return a Portfolio which contains no stocks, and whose title
is an empty String.
|
int |
hashCode() |
boolean |
isUntitled()
Return true only if the name of this Portfolio is an
empty String.
|
void |
setName(String aName)
Set the unique name of this Portfolio.
|
void |
setStocks(Set<Stock> aStocks)
Replace the
Stock objects contained in this Portfolio. |
String |
toString()
Represent this object as a String - intended for debugging
purposes only.
|
public static Portfolio getUntitledPortfolio()
An untitled Portfolio is a special object, which cannot be created either directly (by using the constructor), nor indirectly (by using the constructor and changing object state). These special objects are only obtained through this method.
public boolean isUntitled()
public String getName()
public void setName(String aName)
aName
- see Portfolio(String, Set)
for conditions on aName.public Set<Stock> getStocks()
Stock
objects contained in this Portfolio.
The returned value is unmodifiable. See class description for example of of changing the Stocks in a Portfolio.
public void setStocks(Set<Stock> aStocks)
Stock
objects contained in this Portfolio.aStocks
- see Portfolio(String, Set)
for conditions on aStocks.public List<Quote> getQuotes() throws DataAccessException
Quote
objects, one for each Stock in this
Portfolio.DataAccessException
public BigDecimal getBookValue(Collection<Quote> aQuotes)
Stock
in aQuotes contributes the value
Stock.getBookValue()
.aQuotes
- is a possibly-filtered collection of Quote
objects; see
QuoteFilter
; each Quote object
corresponds to a Stock known to this Portfolio.public BigDecimal getCurrentValue(Collection<Quote> aQuotes)
Quote
contributes the value Quote.getCurrentValue()
.aQuotes
- is a possibly-filtered collection of Quote
objects; see
QuoteFilter
.public BigDecimal getProfit(Collection<Quote> aQuotes)
getCurrentValue(java.util.Collection<hirondelle.stocks.quotes.Quote>)
less getBookValue(java.util.Collection<hirondelle.stocks.quotes.Quote>)
.aQuotes
- is a possibly-filtered collection of Quote
objects; see
QuoteFilter
.public BigDecimal getPercentageProfit(Collection<Quote> aQuotes)
getProfit(java.util.Collection<hirondelle.stocks.quotes.Quote>)
divided by getBookValue(java.util.Collection<hirondelle.stocks.quotes.Quote>)
; if the book value
is zero, then return zero.aQuotes
- is a possibly-filtered collection of Quote
objects; see
QuoteFilter
.public String toString()
Copyright Hirondelle Systems - License - Generated 2013Sep20.10.58