|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectPortfolio
public final class Portfolio
Represents a uniquely-named set of 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 Summary | |
|---|---|
Portfolio(String aName,
Set<Stock> aStocks)
Constructor. |
|
| Method Summary | |
|---|---|
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 divided by getBookValue(java.util.Collection; if the book value
is zero, then return zero. |
BigDecimal |
getProfit(Collection<Quote> aQuotes)
Return getCurrentValue(java.util.Collection less getBookValue(java.util.Collection. |
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. |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Portfolio(String aName,
Set<Stock> aStocks)
aName - is the unique identifier for this Portfolio, has
visible contentaStocks - is possibly-empty, and represents a reference to an
object which is shared with the caller; no defensive copy is made.| Method Detail |
|---|
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.
DataAccessExceptionpublic 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) less getBookValue(java.util.Collection) .
aQuotes - is a possibly-filtered collection of Quote objects; see
QuoteFilter.
public BigDecimal getPercentageProfit(Collection<Quote> aQuotes)
getProfit(java.util.Collection) divided by getBookValue(java.util.Collection) ; if the book value
is zero, then return zero.
aQuotes - is a possibly-filtered collection of Quote objects; see
QuoteFilter.public String toString()
toString in class Objectpublic boolean equals(Object aThat)
equals in class Objectpublic int hashCode()
hashCode in class Object
|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||