-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Restaurant.java
56 lines (43 loc) · 1.25 KB
/
Restaurant.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package net.chrisrichardson.ftgo.orderservice.domain;
import net.chrisrichardson.ftgo.kitchenservice.api.TicketDetails;
import net.chrisrichardson.ftgo.orderservice.api.events.OrderDomainEvent;
import javax.persistence.*;
import java.util.List;
import java.util.Optional;
@Entity
@Table(name = "order_service_restaurants")
@Access(AccessType.FIELD)
public class Restaurant {
@Id
private Long id;
@Embedded
@ElementCollection
@CollectionTable(name = "order_service_restaurant_menu_items")
private List<MenuItem> menuItems;
private String name;
private Restaurant() {
}
public Restaurant(long id, String name, List<MenuItem> menuItems) {
this.id = id;
this.name = name;
this.menuItems = menuItems;
}
public List<OrderDomainEvent> reviseMenu(List<MenuItem> revisedMenu) {
throw new UnsupportedOperationException();
}
public void verifyRestaurantDetails(TicketDetails ticketDetails) {
// TODO - implement me
}
public Long getId() {
return id;
}
public Optional<MenuItem> findMenuItem(String menuItemId) {
return menuItems.stream().filter(mi -> mi.getId().equals(menuItemId)).findFirst();
}
public List<MenuItem> getMenuItems() {
return menuItems;
}
public String getName() {
return name;
}
}