Class InMemoryAccountRepository

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      de.japrost.jabudget.domain.account.Account create​(de.japrost.jabudget.domain.account.Account account)
      Create a new Account with the given values.
      java.lang.Boolean delete​(java.lang.String accountId)
      Delete an Account by its id.
      java.util.Set<de.japrost.jabudget.domain.account.Account> findAll()
      Find all Accounts.
      java.util.Optional<de.japrost.jabudget.domain.account.Account> findById​(java.lang.String id)
      Find an Account by id.
      void replaceAll​(java.util.Set<de.japrost.jabudget.domain.account.Account> accounts)
      Replace all Accounts with the given.
      de.japrost.jabudget.domain.account.Account update​(de.japrost.jabudget.domain.account.Account account)
      Update an existing Account.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InMemoryAccountRepository

        public InMemoryAccountRepository()
    • Method Detail

      • create

        public de.japrost.jabudget.domain.account.Account create​(de.japrost.jabudget.domain.account.Account account)
                                                          throws de.japrost.jabudget.domain.DomainException
        Create a new Account with the given values.

        This implementation stores and gives defensive copies of the given account.

        Specified by:
        create in interface AccountRepository
        Parameters:
        account - the Account to create.
        Returns:
        The account as stored in the repository.
        Throws:
        de.japrost.jabudget.domain.DomainException - with DomainFailure.DUPLICATE_ENTITY if the given account already exists.
      • update

        public de.japrost.jabudget.domain.account.Account update​(de.japrost.jabudget.domain.account.Account account)
                                                          throws de.japrost.jabudget.domain.DomainException
        Update an existing Account.

        This implementation stores and gives defensive copies of the given account.

        Specified by:
        update in interface AccountRepository
        Parameters:
        account - the Account to update.
        Returns:
        The account as stored in the repository.
        Throws:
        de.japrost.jabudget.domain.DomainException - with DomainFailure.MISSING_ENTITY if the given account does not exist.
      • replaceAll

        public void replaceAll​(java.util.Set<de.japrost.jabudget.domain.account.Account> accounts)
        Replace all Accounts with the given. Intended for imports.

        This implementation clears existing and adds defensive copies to store.

        Specified by:
        replaceAll in interface AccountRepository
        Parameters:
        accounts - the Accounts to fill the repository.
      • findById

        public java.util.Optional<de.japrost.jabudget.domain.account.Account> findById​(java.lang.String id)
        Find an Account by id.

        This implementation gives a defensive copy of the stored accounts.

        Specified by:
        findById in interface AccountRepository
        Parameters:
        id - the Account id.
        Returns:
        the Account with the id. An empty Optional if no Account is available for the given id.
      • findAll

        public java.util.Set<de.japrost.jabudget.domain.account.Account> findAll()
        Find all Accounts.

        This implementation gives defensive copies of all stored accounts.

        Specified by:
        findAll in interface AccountRepository
        Returns:
        all available Accounts.
      • delete

        public java.lang.Boolean delete​(java.lang.String accountId)
        Delete an Account by its id.

        This implementation returns Boolean.TRUE always.

        Specified by:
        delete in interface AccountRepository
        Parameters:
        accountId - the id of the Account to delete.
        Returns:
        Boolean.TRUE if the Account does not exist after this operation. It does not indicate that the entity to delete did exist. Returns Boolean.FALSE if the entity could not be deleted.