org.homeunix.thecave.buddi.plugin.api.model.impl
Class MutableDocumentImpl

java.lang.Object
  extended by org.homeunix.thecave.buddi.plugin.api.model.impl.ImmutableModelObjectImpl
      extended by org.homeunix.thecave.buddi.plugin.api.model.impl.MutableModelObjectImpl
          extended by org.homeunix.thecave.buddi.plugin.api.model.impl.MutableDocumentImpl
All Implemented Interfaces:
java.lang.Comparable<ImmutableModelObject>, ImmutableDocument, ImmutableModelObject, MutableDocument

public class MutableDocumentImpl
extends MutableModelObjectImpl
implements MutableDocument, ImmutableDocument


Constructor Summary
MutableDocumentImpl(Document model)
           
 
Method Summary
 void addAccount(MutableAccount account)
          Adds an account to the model
 void addAccountType(MutableAccountType type)
          Adds a type to the model
 void addBudgetCategory(MutableBudgetCategory budgetCategory)
          Adds a budget category to the model
 void addScheduledTransaction(MutableScheduledTransaction scheduledTransaction)
          Adds a scheduled transaction to the model
 void addTransaction(MutableTransaction transaction)
          Adds a transaction to the model
 MutableAccount getAccount(java.lang.String name)
          Returns the account referenced by the given name.
 MutableAccountType getAccountType(java.lang.String name)
          Returns the type referenced by the given name.
 MutableBudgetCategory getBudgetCategory(java.lang.String fullName)
          Returns the budget category referenced by the given full name.
 ImmutableBudgetCategoryType getBudgetCategoryType(BudgetCategoryTypes name)
          Returns an ImmutableBudgetCategoryType object, with the given name.
 ImmutableBudgetCategoryType getBudgetCategoryType(java.lang.String name)
          Returns an ImmutableBudgetCategoryType object, with the given name.
 java.util.List<ImmutableAccount> getImmutableAccounts()
          Returns a list of all immutable accounts in the model
 java.util.List<ImmutableAccountType> getImmutableAccountTypes()
          Returns a list of all immutable types in the model
 java.util.List<ImmutableBudgetCategory> getImmutableBudgetCategories()
          Returns a list of all immutable budget categories in the model
 java.util.List<ImmutableTransaction> getImmutableTransactions()
          Returns a list of all immutable transactions in the model
 java.util.List<ImmutableTransaction> getImmutableTransactions(java.util.Date startDate, java.util.Date endDate)
          Returns a list of all immutable transactions in the model which are between startDate and endDate
 java.util.List<ImmutableTransaction> getImmutableTransactions(ImmutableSource source)
          Returns a list of all immutable transactions in the model which are associatd with the given source
 java.util.List<ImmutableTransaction> getImmutableTransactions(ImmutableSource source, java.util.Date startDate, java.util.Date endDate)
          Returns a list of all immutable transactions in the model which are associated with source and between startDate and endDate
 Document getModel()
          Returns the wrapped object from the underlying data model.
 java.util.List<MutableAccount> getMutableAccounts()
          Returns a list of all immutable accounts in the model
 java.util.List<MutableAccountType> getMutableAccountTypes()
          Returns a list of all immutable types in the model
 java.util.List<MutableBudgetCategory> getMutableBudgetCategories()
          Returns a list of all immutable budget categories in the model
 java.util.List<MutableTransaction> getMutableTransactions()
          Returns a list of all immutable transactions in the model
 java.util.List<MutableTransaction> getMutableTransactions(java.util.Date startDate, java.util.Date endDate)
          Returns a list of all immutable transactions in the model which are between startDate and endDate
 java.util.List<MutableTransaction> getMutableTransactions(MutableSource source)
          Returns a list of all immutable transactions in the model which are associatd with the given source
 java.util.List<MutableTransaction> getMutableTransactions(MutableSource source, java.util.Date startDate, java.util.Date endDate)
          Returns a list of all immutable transactions in the model which are associated with source and between startDate and endDate
 long getNetWorth(java.util.Date date)
          Returns the net worth in the model as of the given date.
 void removeAccount(MutableAccount account)
          Removes the given account from the model
 void removeBudgetCategory(MutableBudgetCategory budgetCategory)
          Removes the given budget category from the model
 void removeScheduledTransaction(MutableScheduledTransaction scheduledTransaction)
          Removes the given scheduled transaction from the model
 void removeTransaction(MutableTransaction transaction)
          Removes the given transaction from the model
 void removeType(MutableAccountType type)
          Removes the given type from the model
 
Methods inherited from class org.homeunix.thecave.buddi.plugin.api.model.impl.ImmutableModelObjectImpl
compareTo, equals, getModified, getRaw, getUid, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.homeunix.thecave.buddi.plugin.api.model.ImmutableModelObject
getModified, getRaw, getUid
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

MutableDocumentImpl

public MutableDocumentImpl(Document model)
Method Detail

addAccount

public void addAccount(MutableAccount account)
                throws ModelException
Description copied from interface: MutableDocument
Adds an account to the model

Specified by:
addAccount in interface MutableDocument
Throws:
ModelException

addBudgetCategory

public void addBudgetCategory(MutableBudgetCategory budgetCategory)
                       throws ModelException
Description copied from interface: MutableDocument
Adds a budget category to the model

Specified by:
addBudgetCategory in interface MutableDocument
Throws:
ModelException

addScheduledTransaction

public void addScheduledTransaction(MutableScheduledTransaction scheduledTransaction)
                             throws ModelException
Description copied from interface: MutableDocument
Adds a scheduled transaction to the model

Specified by:
addScheduledTransaction in interface MutableDocument
Throws:
ModelException

addTransaction

public void addTransaction(MutableTransaction transaction)
                    throws ModelException
Description copied from interface: MutableDocument
Adds a transaction to the model

Specified by:
addTransaction in interface MutableDocument
Throws:
ModelException

addAccountType

public void addAccountType(MutableAccountType type)
                    throws ModelException
Description copied from interface: MutableDocument
Adds a type to the model

Specified by:
addAccountType in interface MutableDocument
Throws:
ModelException

removeAccount

public void removeAccount(MutableAccount account)
                   throws ModelException
Description copied from interface: MutableDocument
Removes the given account from the model

Specified by:
removeAccount in interface MutableDocument
Throws:
ModelException

removeBudgetCategory

public void removeBudgetCategory(MutableBudgetCategory budgetCategory)
                          throws ModelException
Description copied from interface: MutableDocument
Removes the given budget category from the model

Specified by:
removeBudgetCategory in interface MutableDocument
Throws:
ModelException

removeScheduledTransaction

public void removeScheduledTransaction(MutableScheduledTransaction scheduledTransaction)
                                throws ModelException
Description copied from interface: MutableDocument
Removes the given scheduled transaction from the model

Specified by:
removeScheduledTransaction in interface MutableDocument
Throws:
ModelException

removeTransaction

public void removeTransaction(MutableTransaction transaction)
                       throws ModelException
Description copied from interface: MutableDocument
Removes the given transaction from the model

Specified by:
removeTransaction in interface MutableDocument
Throws:
ModelException

removeType

public void removeType(MutableAccountType type)
                throws ModelException
Description copied from interface: MutableDocument
Removes the given type from the model

Specified by:
removeType in interface MutableDocument
Throws:
ModelException

getAccount

public MutableAccount getAccount(java.lang.String name)
Description copied from interface: ImmutableDocument
Returns the account referenced by the given name.

Specified by:
getAccount in interface ImmutableDocument
Specified by:
getAccount in interface MutableDocument
Returns:

getMutableAccounts

public java.util.List<MutableAccount> getMutableAccounts()
Description copied from interface: MutableDocument
Returns a list of all immutable accounts in the model

Specified by:
getMutableAccounts in interface MutableDocument
Returns:

getMutableBudgetCategories

public java.util.List<MutableBudgetCategory> getMutableBudgetCategories()
Description copied from interface: MutableDocument
Returns a list of all immutable budget categories in the model

Specified by:
getMutableBudgetCategories in interface MutableDocument
Returns:

getBudgetCategory

public MutableBudgetCategory getBudgetCategory(java.lang.String fullName)
Description copied from interface: ImmutableDocument
Returns the budget category referenced by the given full name.

Specified by:
getBudgetCategory in interface ImmutableDocument
Specified by:
getBudgetCategory in interface MutableDocument
Returns:

getModel

public Document getModel()
Description copied from interface: ImmutableDocument
Returns the wrapped object from the underlying data model. By accessing this method, you bypass all protection which the Buddi API gives you; it is not recommended to use this method unless you understand the risks associated with it.

Specified by:
getModel in interface ImmutableDocument
Specified by:
getModel in interface MutableDocument
Returns:

getMutableTransactions

public java.util.List<MutableTransaction> getMutableTransactions()
Description copied from interface: MutableDocument
Returns a list of all immutable transactions in the model

Specified by:
getMutableTransactions in interface MutableDocument
Returns:

getMutableTransactions

public java.util.List<MutableTransaction> getMutableTransactions(java.util.Date startDate,
                                                                 java.util.Date endDate)
Description copied from interface: MutableDocument
Returns a list of all immutable transactions in the model which are between startDate and endDate

Specified by:
getMutableTransactions in interface MutableDocument
Returns:

getMutableTransactions

public java.util.List<MutableTransaction> getMutableTransactions(MutableSource source)
Description copied from interface: MutableDocument
Returns a list of all immutable transactions in the model which are associatd with the given source

Specified by:
getMutableTransactions in interface MutableDocument
Returns:

getMutableTransactions

public java.util.List<MutableTransaction> getMutableTransactions(MutableSource source,
                                                                 java.util.Date startDate,
                                                                 java.util.Date endDate)
Description copied from interface: MutableDocument
Returns a list of all immutable transactions in the model which are associated with source and between startDate and endDate

Specified by:
getMutableTransactions in interface MutableDocument
Returns:

getAccountType

public MutableAccountType getAccountType(java.lang.String name)
Description copied from interface: ImmutableDocument
Returns the type referenced by the given name.

Specified by:
getAccountType in interface ImmutableDocument
Specified by:
getAccountType in interface MutableDocument
Returns:

getMutableAccountTypes

public java.util.List<MutableAccountType> getMutableAccountTypes()
Description copied from interface: MutableDocument
Returns a list of all immutable types in the model

Specified by:
getMutableAccountTypes in interface MutableDocument
Returns:

getImmutableAccounts

public java.util.List<ImmutableAccount> getImmutableAccounts()
Description copied from interface: ImmutableDocument
Returns a list of all immutable accounts in the model

Specified by:
getImmutableAccounts in interface ImmutableDocument
Returns:

getImmutableBudgetCategories

public java.util.List<ImmutableBudgetCategory> getImmutableBudgetCategories()
Description copied from interface: ImmutableDocument
Returns a list of all immutable budget categories in the model

Specified by:
getImmutableBudgetCategories in interface ImmutableDocument
Returns:

getImmutableTransactions

public java.util.List<ImmutableTransaction> getImmutableTransactions()
Description copied from interface: ImmutableDocument
Returns a list of all immutable transactions in the model

Specified by:
getImmutableTransactions in interface ImmutableDocument
Returns:

getImmutableTransactions

public java.util.List<ImmutableTransaction> getImmutableTransactions(java.util.Date startDate,
                                                                     java.util.Date endDate)
Description copied from interface: ImmutableDocument
Returns a list of all immutable transactions in the model which are between startDate and endDate

Specified by:
getImmutableTransactions in interface ImmutableDocument
Returns:

getImmutableTransactions

public java.util.List<ImmutableTransaction> getImmutableTransactions(ImmutableSource source)
Description copied from interface: ImmutableDocument
Returns a list of all immutable transactions in the model which are associatd with the given source

Specified by:
getImmutableTransactions in interface ImmutableDocument
Returns:

getImmutableTransactions

public java.util.List<ImmutableTransaction> getImmutableTransactions(ImmutableSource source,
                                                                     java.util.Date startDate,
                                                                     java.util.Date endDate)
Description copied from interface: ImmutableDocument
Returns a list of all immutable transactions in the model which are associated with source and between startDate and endDate

Specified by:
getImmutableTransactions in interface ImmutableDocument
Returns:

getImmutableAccountTypes

public java.util.List<ImmutableAccountType> getImmutableAccountTypes()
Description copied from interface: ImmutableDocument
Returns a list of all immutable types in the model

Specified by:
getImmutableAccountTypes in interface ImmutableDocument
Returns:

getBudgetCategoryType

public ImmutableBudgetCategoryType getBudgetCategoryType(BudgetCategoryTypes name)
Description copied from interface: ImmutableDocument
Returns an ImmutableBudgetCategoryType object, with the given name. If the name is not a valid one, returns null.

Specified by:
getBudgetCategoryType in interface ImmutableDocument
Returns:

getBudgetCategoryType

public ImmutableBudgetCategoryType getBudgetCategoryType(java.lang.String name)
Description copied from interface: ImmutableDocument
Returns an ImmutableBudgetCategoryType object, with the given name. If the name is not a valid one, returns null. Although this method gives the same results as the other one, given the same input, it is recommeneded to use the one which takes an enum if possible. That will ensure that you do not make any mistakes with spelling, which may cause a null to be returned.

Specified by:
getBudgetCategoryType in interface ImmutableDocument
Returns:

getNetWorth

public long getNetWorth(java.util.Date date)
Description copied from interface: ImmutableDocument
Returns the net worth in the model as of the given date. This is calculated by summing the account balances for all accounts as of the given date. If the given date is null, return the current balance of the account, as of the last transaction (regardless of date).

Specified by:
getNetWorth in interface ImmutableDocument
Parameters:
date - The date on which to calculate the net worth. Set this to null to return the balance as of the last transaction.
Returns: