streams - Übungen - Microservices - Schritt 03
[demos/microservices] / take-order / src / main / java / de / trion / microservices / takeorder / OrderBean.java
1 package de.trion.microservices.takeorder;
2
3 import javax.validation.constraints.NotNull;
4
5
6 /**
7  * Simple DTO used by the REST interface
8  */
9 public class OrderBean
10 {
11   @NotNull(message = "Cannot be null")
12   private long id;
13   @NotNull(message = "Cannot be null")
14   private long customerId;
15   @NotNull(message = "Cannot be null")
16   private long productId;
17   @NotNull(message = "Cannot be null")
18   private int quantity;
19
20
21   public OrderBean() {}
22
23   public OrderBean(
24       final long id,
25       final long customerId,
26       final long productId,
27       final int quantity)
28   {
29     this.id = id;
30     this.customerId = customerId;
31     this.productId = productId;
32     this.quantity = quantity;
33   }
34
35   public long getId()
36   {
37     return id;
38   }
39
40   public long getCustomerId()
41   {
42     return customerId;
43   }
44
45   public long getProductId()
46   {
47     return productId;
48   }
49
50   public int getQuantity()
51   {
52     return quantity;
53   }
54
55
56   @Override
57   public boolean equals(final Object o) {
58     if (this == o)
59       return true;
60     if (o == null || this.getClass() != o.getClass())
61       return false;
62
63     final OrderBean orderBean = (OrderBean) o;
64
65     return this.customerId == orderBean.customerId;
66   }
67
68   @Override
69   public String toString()
70   {
71     return "{" +
72         "id=" + id +
73         ", customerId=" + customerId +
74         ", productId=" + productId +
75         ", quantity=" + quantity +
76         '}';
77   }
78
79   @Override
80   public int hashCode()
81   {
82     return Long.hashCode(this.id);
83   }
84 }