Interface Accountancy
An application service to manage
AccountancyEntry
s and to create basic financial statistics.- Author:
- Hannes Weisbach, Oliver Drotbohm, Martin Morgenstern
-
Method Summary
Modifier and TypeMethodDescription<T extends AccountancyEntry>
Tadd
(T entry) Adds a newAccountancyEntry
to thisAccountancy
.<T extends AccountancyEntry>
Streamable<T>Returns allAccountancyEntry
s of the given type for the givenInterval
.find
(Interval interval, TemporalAmount duration) Returns allAccountancyEntry
s within the given interval, grouped by sub-intervals of the given duration.<T extends AccountancyEntry>
Map<Interval,Streamable<T>> find
(Interval interval, TemporalAmount duration, Class<T> type) Returns allAccountancyEntry
s of the given type within the given interval, grouped by sub-intervals of the given duration.findAll()
Returns allAccountancyEntry
s previously added to the accountancy.<T extends AccountancyEntry>
Streamable<T>Returns allAccountancyEntry
instances of the given types, and the given types only.get
(AccountancyEntry.AccountancyEntryIdentifier identifier) Returns theAccountancyEntry
identified by the givenAccountancyEntry.AccountancyEntryIdentifier
, if it exists.<T extends AccountancyEntry>
Optional<T>get
(AccountancyEntry.AccountancyEntryIdentifier identifier, Class<T> type) Returns theAccountancyEntry
identified by the givenAccountancyEntry.AccountancyEntryIdentifier
of the given type, if it exists.salesVolume
(Interval interval, TemporalAmount duration) Computes the sales volume, i.e., the sum ofAccountancyEntry.getValue()
, for allAccountancyEntry
s within the given interval, grouped by sub-intervals of the given duration.
-
Method Details
-
add
Adds a newAccountancyEntry
to thisAccountancy
. TheAccountancyEntry
's date will be set to the value returned byBusinessTime.getTime()
in case it is not set already.- Parameters:
entry
- entry to be added to the accountancy, must not be null.- Returns:
- the added
AccountancyEntry
.
-
findAll
Streamable<AccountancyEntry> findAll()Returns allAccountancyEntry
s previously added to the accountancy.- Returns:
- a
Streamable
containing all entries, or an emptyStreamable
.
-
findAll
Returns allAccountancyEntry
instances of the given types, and the given types only. This means the asking for intermediate types in an inheritance hierarchy is not sufficient. All leaf types of the hierarchy would have to be passed in.- Type Parameters:
T
- the concrete subtype ofAccountancyEntry
.- Parameters:
type
- must not be null.- Returns:
- will never be null.
- Since:
- 9.0
-
get
Returns theAccountancyEntry
identified by the givenAccountancyEntry.AccountancyEntryIdentifier
, if it exists.- Parameters:
identifier
- theAccountancyEntry.AccountancyEntryIdentifier
of the entry to be returned, must not be null.- Returns:
- an
Optional
with a matchingAccountancyEntry
, or an emptyOptional
if no match was found.
-
get
<T extends AccountancyEntry> Optional<T> get(AccountancyEntry.AccountancyEntryIdentifier identifier, Class<T> type) Returns theAccountancyEntry
identified by the givenAccountancyEntry.AccountancyEntryIdentifier
of the given type, if it exists.- Parameters:
identifier
- theAccountancyEntry.AccountancyEntryIdentifier
of the entry to be returned, must not be null.type
- the concreteAccountancyEntry
type, must not be null.- Returns:
- an
Optional
with a matchingAccountancyEntry
, or an emptyOptional
if no match was found. - Since:
- 9.0
-
find
- Parameters:
interval
- the interval within which we want to findAccountancyEntry
s, must not be null.- Returns:
- a
Streamable
containing all entries in the given interval, or an emptyStreamable
.
-
find
Returns allAccountancyEntry
s of the given type for the givenInterval
.- Type Parameters:
T
-- Parameters:
interval
- must not be null.type
- must not be null.- Returns:
- will never be null.
- Since:
- 9.0
-
find
Returns allAccountancyEntry
s within the given interval, grouped by sub-intervals of the given duration. These sub-intervals are used as the keys of the returnedMap
. Note that the last sub-interval may be shorter than the givenduration
.- Parameters:
interval
- the interval within which we want to findAccountancyEntry
s, must not be null.duration
- the duration of the sub-intervals, must not be null.- Returns:
- a
Map
containing aStreamable
with zero or moreAccountancyEntry
s for each sub-interval.
-
find
<T extends AccountancyEntry> Map<Interval,Streamable<T>> find(Interval interval, TemporalAmount duration, Class<T> type) Returns allAccountancyEntry
s of the given type within the given interval, grouped by sub-intervals of the given duration. These sub-intervals are used as the keys of the returnedMap
. Note that the last sub-interval may be shorter than the givenduration
.- Parameters:
interval
- the interval within which we want to findAccountancyEntry
s, must not be null.duration
- the duration of the sub-intervals, must not be null.type
-- Returns:
- a
Map
containing aStreamable
with zero or moreAccountancyEntry
s for each sub-interval. - Since:
- 9.0
-
salesVolume
Computes the sales volume, i.e., the sum ofAccountancyEntry.getValue()
, for allAccountancyEntry
s within the given interval, grouped by sub-intervals of the given duration. If a sub-interval doesn't contain anAccountancyEntry
, its sales volume is zero. Note that the last sub-interval may be shorter than the givenduration
.- Parameters:
interval
- the interval within which we want to findAccountancyEntry
s, must not be null.duration
- the duration of the sub-intervals that are used to group the summation, must not be null.- Returns:
- a
Map
containing the summed upMonetaryAmount
for each sub-interval.
-