@Service @Transactional class PersistentOrderManager<T extends Order> extends Object implements OrderManager<T>
| Constructor and Description |
|---|
PersistentOrderManager(BusinessTime businessTime,
OrderRepository<T> orderRepository) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancelOrder(T order)
|
void |
completeOrder(T order)
Tries to complete this order, the
OrderStatus has to be OrderStatus.PAID. |
boolean |
contains(OrderIdentifier orderIdentifier)
Checks if this
OrderManager contains an order. |
Streamable<T> |
findBy(Interval interval)
|
Streamable<T> |
findBy(OrderStatus orderStatus)
|
Streamable<T> |
findBy(UserAccount userAccount)
Returns all
Orders of the given UserAccount. |
Streamable<T> |
findBy(UserAccount userAccount,
Interval interval)
Returns all
Orders from the given UserAccount in between the dates from and to,
including from and to. |
Optional<T> |
get(OrderIdentifier orderIdentifier)
Returns the order identified by an
OrderIdentifier |
boolean |
payOrder(T order)
|
T |
save(T order)
Saves the given
Order or persists changes to it. |
@ConstructorProperties(value={"businessTime","orderRepository"}) @Generated(value="lombok") public PersistentOrderManager(@NonNull BusinessTime businessTime, @NonNull OrderRepository<T> orderRepository)
public T save(T order)
OrderManagerOrder or persists changes to it.save in interface OrderManager<T extends Order>order - the order to be saved, must not be null.public Optional<T> get(OrderIdentifier orderIdentifier)
OrderManagerOrderIdentifierget in interface OrderManager<T extends Order>orderIdentifier - identifier of the Order to be returned, must not be null.Optional.empty().public boolean contains(OrderIdentifier orderIdentifier)
OrderManagerOrderManager contains an order.contains in interface OrderManager<T extends Order>orderIdentifier - the OrderIdentifier of the Order, must not be null.public Streamable<T> findBy(Interval interval)
OrderManagerOrders in between the Interval. So every entry with an time stamp <= to and >= from is
returned. If no Orders within the specified time span exist, an empty Iterable is returned.findBy in interface OrderManager<T extends Order>interval - The time interval to find Orders in, must not be null.Streamable containing all Orders in the given Interval.public Streamable<T> findBy(OrderStatus orderStatus)
OrderManagerOrders having the OrderStatus status. If no orders with the specified status
exist, an empty Iterable is returned.findBy in interface OrderManager<T extends Order>orderStatus - Denoting the OrderStatus on which the Orders will be requested.Streamable containing all Orders with the specified OrderStatuspublic Streamable<T> findBy(UserAccount userAccount)
OrderManagerOrders of the given UserAccount. If this user has no orders, an empty Iterable
is returned.findBy in interface OrderManager<T extends Order>userAccount - Denoting the UserAccount on which the orders will be requested, must not be
null.Streamable containing all orders of the specified user.public Streamable<T> findBy(UserAccount userAccount, Interval interval)
OrderManagerOrders from the given UserAccount in between the dates from and to,
including from and to. So every entry with an time stamp <= to and >= from is returned. If this user has no
Orders in this period, an empty Iterable is returned.findBy in interface OrderManager<T extends Order>userAccount - The UserAccount whose Orders shall be returned, must not be null.interval - The time interval to find Orders in, must not be null.Streamable containing all orders from the specified user in the specified period.public void completeOrder(T order)
OrderManagerOrderStatus has to be OrderStatus.PAID.completeOrder in interface OrderManager<T extends Order>order - the order to complete, must not be null.public boolean payOrder(T order)
OrderManagerpayOrder in interface OrderManager<T extends Order>order - the order to be payed, must not be null.public boolean cancelOrder(T order)
OrderManagercancelOrder in interface OrderManager<T extends Order>order - the order to be canceled, must not be null.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.