Package org.salespointframework.order
Interface OrderManager<T extends Order>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
cancelOrder(T order)
Cancels anOrder
, no matter what state it is in.void
completeOrder(T order)
Tries to complete this order, theOrderStatus
has to beOrderStatus.PAID
.boolean
contains(OrderIdentifier orderIdentifier)
Checks if thisOrderManager
contains an order.T
delete(T order)
Deletes the givenOrder
.org.springframework.data.domain.Page<T>
findAll(org.springframework.data.domain.Pageable pageable)
Returns thePage
of orders specified by the givenPageable
.org.springframework.data.util.Streamable<T>
findBy(OrderStatus orderStatus)
org.springframework.data.util.Streamable<T>
findBy(Interval interval)
org.springframework.data.util.Streamable<T>
findBy(UserAccount userAccount)
Returns allOrder
s of the givenUserAccount
.org.springframework.data.util.Streamable<T>
findBy(UserAccount userAccount, Interval interval)
Returns allOrder
s from the givenUserAccount
in between the datesfrom
andto
, including from and to.Optional<T>
get(OrderIdentifier orderIdentifier)
Returns the order identified by anOrderIdentifier
boolean
payOrder(T order)
T
save(T order)
Saves the givenOrder
or persists changes to it.
-
-
-
Method Detail
-
save
T save(T order)
Saves the givenOrder
or persists changes to it.- Parameters:
order
- the order to be saved, must not be null.- Returns:
-
get
Optional<T> get(OrderIdentifier orderIdentifier)
Returns the order identified by anOrderIdentifier
- Parameters:
orderIdentifier
- identifier of theOrder
to be returned, must not be null.- Returns:
- the order if the orderIdentifier matches, otherwise
Optional.empty()
.
-
contains
boolean contains(OrderIdentifier orderIdentifier)
Checks if thisOrderManager
contains an order.- Parameters:
orderIdentifier
- theOrderIdentifier
of theOrder
, must not be null.- Returns:
- true if the OrderManager contains the order, false otherwise.
-
findBy
org.springframework.data.util.Streamable<T> findBy(OrderStatus orderStatus)
Returns allOrder
s having theOrderStatus
status
. If no orders with the specified status exist, an empty Iterable is returned.- Parameters:
orderStatus
- Denoting theOrderStatus
on which theOrder
s will be requested.- Returns:
- a
Streamable
containing allOrder
s with the specifiedOrderStatus
-
findBy
org.springframework.data.util.Streamable<T> findBy(UserAccount userAccount)
Returns allOrder
s of the givenUserAccount
. If this user has no orders, an emptyIterable
is returned.- Parameters:
userAccount
- Denoting theUserAccount
on which the orders will be requested, must not be null.- Returns:
- a
Streamable
containing all orders of the specified user.
-
findBy
org.springframework.data.util.Streamable<T> findBy(UserAccount userAccount, Interval interval)
Returns allOrder
s from the givenUserAccount
in between the datesfrom
andto
, including from and to. So every entry with an time stamp <= to and >= from is returned. If this user has noOrder
s in this period, an emptyIterable
is returned.- Parameters:
userAccount
- TheUserAccount
whoseOrder
s shall be returned, must not be null.interval
- The time interval to findOrder
s in, must not be null.- Returns:
- a
Streamable
containing all orders from the specified user in the specified period.
-
completeOrder
void completeOrder(T order) throws OrderCompletionFailure
Tries to complete this order, theOrderStatus
has to beOrderStatus.PAID
.- Parameters:
order
- the order to complete, must not be null.- Throws:
OrderCompletionFailure
- in case the order can't be completed.- See Also:
Order.OrderCompleted
-
payOrder
boolean payOrder(T order)
- Parameters:
order
- the order to be payed, must not be null.- Returns:
- true if the order could be paid
- See Also:
Order.OrderPaid
-
cancelOrder
boolean cancelOrder(T order)
Cancels anOrder
, no matter what state it is in.- Parameters:
order
- the order to be canceled, must not be null.- Returns:
- true if the order could be canceled
- See Also:
Order.OrderCancelled
-
delete
T delete(T order)
Deletes the givenOrder
.- Parameters:
order
- must not be null.- Returns:
- the deleted
Order
- Since:
- 7.1
-
findAll
org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
Returns thePage
of orders specified by the givenPageable
.- Returns:
- the
Page
of orders specified by the givenPageable
. - Since:
- 7.1
-
-