// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
// 
//   public OrderId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static OrderId randomId() {
//     return new OrderId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
// 
//   private final OrderId orderId;
//   private final long orderPlacedTimestamp;
//   private final long orderAmount;
//   private final String customerName;
//   private final List<OrderLineProjection> orderLines;
//   private OrderStatus status;
// 
//   public OrderProjection(@JsonProperty("orderId") OrderId orderId,
//                          @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
//                          @JsonProperty("customerName") String customerName,
//                          @JsonProperty("orderAmount") long orderAmount,
//                          @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
//                          @JsonProperty("status") OrderStatus status) {
//     this.orderId = orderId;
//     this.orderPlacedTimestamp = orderPlacedTimestamp;
//     this.customerName = customerName;
//     this.orderAmount = orderAmount;
//     this.orderLines = new ArrayList<>(orderLines);
//     this.status = status;
//   }
// 
//   public List<OrderLineProjection> getOrderLines() {
//     return orderLines;
//   }
// 
//   public OrderId getOrderId() {
//     return orderId;
//   }
// 
//   public String getCustomerName() {
//     return customerName;
//   }
// 
//   public long getOrderAmount() {
//     return orderAmount;
//   }
// 
//   public OrderStatus getStatus() {
//     return status;
//   }
// 
//   public void setStatus(OrderStatus status) {
//     this.status = status;
//   }
// 
//   public long getOrderPlacedTimestamp() {
//     return orderPlacedTimestamp;
//   }
// 
// }
// 
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
// 
//   void save(OrderProjection orderProjection);
// 
//   OrderProjection getById(OrderId orderId);
// 
//   List<OrderProjection> listOrdersByTimestamp();
// 
// }


import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.*;
package se.citerus.cqrs.bookstore.ordercontext.infrastructure;



public class InMemOrderProjectionRepository implements OrderProjectionRepository {

  private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
  private final Map<OrderId, OrderProjection> orders = new HashMap<>();

  private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
    orders.put(orderId, orderProjection);
  }

  @Override
  public void save(OrderProjection orderProjection) {
    saveOrder(orderProjection.getOrderId(), orderProjection);
  }

  @Override
  public OrderProjection getById(OrderId orderId) {
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
// 
//   public OrderId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static OrderId randomId() {
//     return new OrderId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjection.java
// public class OrderProjection extends Projection {
// 
//   private final OrderId orderId;
//   private final long orderPlacedTimestamp;
//   private final long orderAmount;
//   private final String customerName;
//   private final List<OrderLineProjection> orderLines;
//   private OrderStatus status;
// 
//   public OrderProjection(@JsonProperty("orderId") OrderId orderId,
//                          @JsonProperty("orderPlacedTimestamp") long orderPlacedTimestamp,
//                          @JsonProperty("customerName") String customerName,
//                          @JsonProperty("orderAmount") long orderAmount,
//                          @JsonProperty("orderLines") List<OrderLineProjection> orderLines,
//                          @JsonProperty("status") OrderStatus status) {
//     this.orderId = orderId;
//     this.orderPlacedTimestamp = orderPlacedTimestamp;
//     this.customerName = customerName;
//     this.orderAmount = orderAmount;
//     this.orderLines = new ArrayList<>(orderLines);
//     this.status = status;
//   }
// 
//   public List<OrderLineProjection> getOrderLines() {
//     return orderLines;
//   }
// 
//   public OrderId getOrderId() {
//     return orderId;
//   }
// 
//   public String getCustomerName() {
//     return customerName;
//   }
// 
//   public long getOrderAmount() {
//     return orderAmount;
//   }
// 
//   public OrderStatus getStatus() {
//     return status;
//   }
// 
//   public void setStatus(OrderStatus status) {
//     this.status = status;
//   }
// 
//   public long getOrderPlacedTimestamp() {
//     return orderPlacedTimestamp;
//   }
// 
// }
// 
// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/query/orderlist/OrderProjectionRepository.java
// public interface OrderProjectionRepository {
// 
//   void save(OrderProjection orderProjection);
// 
//   OrderProjection getById(OrderId orderId);
// 
//   List<OrderProjection> listOrdersByTimestamp();
// 
// }


// Path: order-context-parent/order-query/src/main/java/se/citerus/cqrs/bookstore/ordercontext/infrastructure/InMemOrderProjectionRepository.java
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjection;
import se.citerus.cqrs.bookstore.ordercontext.query.orderlist.OrderProjectionRepository;
import java.util.*;

package se.citerus.cqrs.bookstore.ordercontext.infrastructure;



public class InMemOrderProjectionRepository implements OrderProjectionRepository {

  private static final OrderTimestampComparator ORDER_TIMESTAMP_COMPARATOR = new OrderTimestampComparator();
  private final Map<OrderId, OrderProjection> orders = new HashMap<>();

  private void saveOrder(OrderId orderId, OrderProjection orderProjection) {
    orders.put(orderId, orderProjection);
  }

  @Override
  public void save(OrderProjection orderProjection) {
    saveOrder(orderProjection.getOrderId(), orderProjection);
  }

  @Override
  public OrderProjection getById(OrderId orderId) {
    return orders.get(orderId);