| 35501 |
ranu |
1 |
package com.spice.profitmandi.dao.model;
|
|
|
2 |
|
|
|
3 |
import java.util.Collections;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
import java.util.Objects;
|
|
|
6 |
import java.util.stream.Collectors;
|
|
|
7 |
|
|
|
8 |
public class TodayOfferGroupKey {
|
|
|
9 |
|
|
|
10 |
private final List<Integer> catalogOfferIds;
|
|
|
11 |
private final List<Integer> schemeOfferIds;
|
|
|
12 |
private final List<Integer> customerOfferIds;
|
|
|
13 |
private final List<Integer> webOfferIds;
|
|
|
14 |
|
|
|
15 |
public TodayOfferGroupKey(TodayOfferModel m) {
|
|
|
16 |
|
|
|
17 |
this.catalogOfferIds = safe(m.getTodayCatalogOfferModels())
|
|
|
18 |
.stream()
|
|
|
19 |
.map(TodayCatalogOfferModel::getOfferId)
|
|
|
20 |
.sorted()
|
|
|
21 |
.collect(Collectors.toList());
|
|
|
22 |
|
|
|
23 |
this.schemeOfferIds = safe(m.getSchemeOfferModels())
|
|
|
24 |
.stream()
|
|
|
25 |
.map(SchemeOfferModel::getSchemeId)
|
|
|
26 |
.sorted()
|
|
|
27 |
.collect(Collectors.toList());
|
|
|
28 |
|
|
|
29 |
this.customerOfferIds = safe(m.getCustomerOfferItemModels())
|
|
|
30 |
.stream()
|
|
|
31 |
.map(CustomerOfferItemModel::getOfferId)
|
|
|
32 |
.sorted()
|
|
|
33 |
.collect(Collectors.toList());
|
|
|
34 |
|
|
|
35 |
this.webOfferIds = safe(m.getWebOfferModels())
|
|
|
36 |
.stream()
|
|
|
37 |
.map(WebOfferModel::getId)
|
|
|
38 |
.sorted()
|
|
|
39 |
.collect(Collectors.toList());
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
private <T> List<T> safe(List<T> list) {
|
|
|
43 |
return list == null ? Collections.emptyList() : list;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
@Override
|
|
|
47 |
public boolean equals(Object o) {
|
|
|
48 |
if (this == o) return true;
|
|
|
49 |
if (!(o instanceof TodayOfferGroupKey)) return false;
|
|
|
50 |
TodayOfferGroupKey that = (TodayOfferGroupKey) o;
|
|
|
51 |
return Objects.equals(catalogOfferIds, that.catalogOfferIds)
|
|
|
52 |
&& Objects.equals(schemeOfferIds, that.schemeOfferIds)
|
|
|
53 |
&& Objects.equals(customerOfferIds, that.customerOfferIds)
|
|
|
54 |
&& Objects.equals(webOfferIds, that.webOfferIds);
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
@Override
|
|
|
58 |
public int hashCode() {
|
|
|
59 |
return Objects.hash(
|
|
|
60 |
catalogOfferIds,
|
|
|
61 |
schemeOfferIds,
|
|
|
62 |
customerOfferIds,
|
|
|
63 |
webOfferIds
|
|
|
64 |
);
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
|