Package org.salespointframework.order
Interface OrderManager<T extends Order>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancancelOrder(T order)Cancels anOrder, no matter what state it is in.voidcompleteOrder(T order)Tries to complete this order, theOrderStatushas to beOrderStatus.PAID.booleancontains(OrderIdentifier orderIdentifier)Checks if thisOrderManagercontains an order.Tdelete(T order)Deletes the givenOrder.org.springframework.data.domain.Page<T>findAll(org.springframework.data.domain.Pageable pageable)Returns thePageof 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 allOrders of the givenUserAccount.org.springframework.data.util.Streamable<T>findBy(UserAccount userAccount, Interval interval)Returns allOrders from the givenUserAccountin between the datesfromandto, including from and to.Optional<T>get(OrderIdentifier orderIdentifier)Returns the order identified by anOrderIdentifierbooleanpayOrder(T order)Tsave(T order)Saves the givenOrderor persists changes to it.
-
-
-
Method Detail
-
save
T save(T order)
Saves the givenOrderor 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 theOrderto be returned, must not be null.- Returns:
- the order if the orderIdentifier matches, otherwise
Optional.empty().
-
contains
boolean contains(OrderIdentifier orderIdentifier)
Checks if thisOrderManagercontains an order.- Parameters:
orderIdentifier- theOrderIdentifierof 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 allOrders having theOrderStatusstatus. If no orders with the specified status exist, an empty Iterable is returned.- Parameters:
orderStatus- Denoting theOrderStatuson which theOrders will be requested.- Returns:
- a
Streamablecontaining allOrders with the specifiedOrderStatus
-
findBy
org.springframework.data.util.Streamable<T> findBy(UserAccount userAccount)
Returns allOrders of the givenUserAccount. If this user has no orders, an emptyIterableis returned.- Parameters:
userAccount- Denoting theUserAccounton which the orders will be requested, must not be null.- Returns:
- a
Streamablecontaining all orders of the specified user.
-
findBy
org.springframework.data.util.Streamable<T> findBy(UserAccount userAccount, Interval interval)
Returns allOrders from the givenUserAccountin between the datesfromandto, including from and to. So every entry with an time stamp <= to and >= from is returned. If this user has noOrders in this period, an emptyIterableis returned.- Parameters:
userAccount- TheUserAccountwhoseOrders shall be returned, must not be null.interval- The time interval to findOrders in, must not be null.- Returns:
- a
Streamablecontaining all orders from the specified user in the specified period.
-
completeOrder
void completeOrder(T order) throws OrderCompletionFailure
Tries to complete this order, theOrderStatushas 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 thePageof orders specified by the givenPageable.- Returns:
- the
Pageof orders specified by the givenPageable. - Since:
- 7.1
-
-