@Service @Transactional class PersistentAccountancy extends Object implements Accountancy
AccountancyEntry
s.Constructor and Description |
---|
PersistentAccountancy(BusinessTime businessTime,
AccountancyEntryRepository repository) |
Modifier and Type | Method and Description |
---|---|
<T extends AccountancyEntry> |
add(T accountancyEntry)
Adds a new
AccountancyEntry to this Accountancy . |
Streamable<AccountancyEntry> |
find(Interval interval)
Returns all
AccountancyEntry s that were created in the given Interval . |
Map<Interval,Streamable<AccountancyEntry>> |
find(Interval interval,
TemporalAmount duration)
|
Streamable<AccountancyEntry> |
findAll()
Returns all
AccountancyEntry s of the specified type clazz and all sub-types, previously added to
the accountancy. |
Optional<AccountancyEntry> |
get(AccountancyEntryIdentifier accountancyEntryIdentifier)
Returns the
AccountancyEntry of type clazz and all sub-types, identified by
AccountancyEntryIdentifier . |
Map<Interval,javax.money.MonetaryAmount> |
salesVolume(Interval interval,
TemporalAmount duration)
Returns the sum of the field
amount of all AccountancyEntry s which have their date within
(including) from and to . |
@ConstructorProperties(value={"businessTime","repository"}) @Generated(value="lombok") public PersistentAccountancy(@NonNull BusinessTime businessTime, @NonNull AccountancyEntryRepository repository)
public final <T extends AccountancyEntry> T add(T accountancyEntry)
Accountancy
AccountancyEntry
to this Accountancy
.add
in interface Accountancy
accountancyEntry
- entry to be added to the accountancypublic final Optional<AccountancyEntry> get(AccountancyEntryIdentifier accountancyEntryIdentifier)
Accountancy
AccountancyEntry
of type clazz
and all sub-types, identified by
AccountancyEntryIdentifier
. null is returned, if no entry with the given identifier exists.get
in interface Accountancy
accountancyEntryIdentifier
- the AccountancyEntryIdentifier
of the entry to be returnedAccountancyEntry
or sub type thereof of type clazz
which has the identifier
AccountancyEntryIdentifier
public final Streamable<AccountancyEntry> findAll()
Accountancy
AccountancyEntry
s of the specified type clazz
and all sub-types, previously added to
the accountancy. If no entries of the specified type exist, an empty Iterable
is returned.findAll
in interface Accountancy
Streamable
containing all entries of type clazzpublic final Streamable<AccountancyEntry> find(Interval interval)
Accountancy
AccountancyEntry
s that were created in the given Interval
. So every entry with an time
stamp <= to
and >= from
is returned. If no entries within the specified time span exist, or no
entries of the specified class type exist, an empty Streamable
is returned.find
in interface Accountancy
interval
- the Interval
we want to find AccountancyEntry
instances for.Streamable
containing all entries in the given Interval
.public final Map<Interval,Streamable<AccountancyEntry>> find(Interval interval, TemporalAmount duration)
Accountancy
AccountancyEntry
s which have their date
within the given Interval
. The
Interval
is divided into parts of length of the given Duration
. According to their respective date,
entries are sorted in exactly one of the time intervals. The last time interval may be shorter than the given
Duration
. Returned is a map, having a Interval
objects as its key, and an Streamable
as
value. The Streamable
contains all entries of the specific type with its date in the interval specified by
the key.find
in interface Accountancy
duration
- length of the time intervals, the period between from
and to
is dividedperiod
length between from
and to
as keys, and as value an
Iterable
containing all entries within the key- Interval
public final Map<Interval,javax.money.MonetaryAmount> salesVolume(Interval interval, TemporalAmount duration)
Accountancy
amount
of all AccountancyEntry
s which have their date
within
(including) from
and to
. from
and to
is divided into parts of period
length. According to their
time stamp, entries are sorted in exactly one of the time intervals. The last time interval may be shorter than
period
.Interval
objects as its key, and a MonetaryAmount
as value. The
MonetaryAmount
object's value is equal to the sum of all entries' amount
-field, with a date within
the key- Interval
. If within an interval no entries of the specified type exist, a MonetaryAmount
object with a value of zero is added as value for that interval.salesVolume
in interface Accountancy
duration
- length of the time intervals, the period between from
and to
is divided.Map
, with intervals of period
length between from
and to
as keys, and as
value a MonetaryAmount
object, equal to the sum of the amount fields of all entries within the key-
Interval
.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.