Repository navigation
Expand file tree
/
Copy pathInvoiceItem.java
More file actions
59 lines (46 loc) · 1.65 KB
/
Copy pathInvoiceItem.java
File metadata and controls
59 lines (46 loc) · 1.65 KB
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
57
58
59
package de.codecentric.java8examples;
import java.math.BigDecimal;
public class InvoiceItem {
private String product;
private Integer quantity;
private BigDecimal pricePerUnit;
public String getProduct() {
return product;
}
public Integer getQuantity() {
return quantity;
}
public BigDecimal getPricePerUnit() {
return pricePerUnit;
}
public InvoiceItem(String product, Integer quantity, BigDecimal pricePerUnit) {
this.product = product;
this.quantity = quantity;
this.pricePerUnit = pricePerUnit;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InvoiceItem that = (InvoiceItem) o;
if (pricePerUnit != null ? !pricePerUnit.equals(that.pricePerUnit) : that.pricePerUnit != null) return false;
if (product != null ? !product.equals(that.product) : that.product != null) return false;
if (quantity != null ? !quantity.equals(that.quantity) : that.quantity != null) return false;
return true;
}
@Override
public int hashCode() {
int result = product != null ? product.hashCode() : 0;
result = 31 * result + (quantity != null ? quantity.hashCode() : 0);
result = 31 * result + (pricePerUnit != null ? pricePerUnit.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "InvoiceItem{" +
"product='" + product + '\'' +
", quantity=" + quantity +
", pricePerUnit=" + pricePerUnit +
'}';
}
}