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