1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.prometheus.maps;
18
19 import io.github.tonywasher.joceanus.oceanus.format.OceanusDataFormatter;
20 import io.github.tonywasher.joceanus.metis.data.MetisDataResource;
21 import io.github.tonywasher.joceanus.metis.field.MetisFieldItem;
22 import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
23 import io.github.tonywasher.joceanus.metis.list.MetisListKey;
24 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataItem;
25 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataResource;
26
27 import java.util.Objects;
28
29
30
31
32 public class PrometheusMapsItemId
33 implements MetisFieldItem {
34
35
36
37 private static final MetisFieldSet<PrometheusMapsItemId> FIELD_DEFS
38 = MetisFieldSet.newFieldSet(PrometheusMapsItemId.class);
39
40
41
42
43 static {
44 FIELD_DEFS.declareLocalField(PrometheusDataResource.DATAITEM_TYPE, PrometheusMapsItemId::getListKey);
45 FIELD_DEFS.declareLocalField(MetisDataResource.DATA_ID, PrometheusMapsItemId::getItemId);
46 }
47
48
49
50
51 private final MetisListKey theListKey;
52
53
54
55
56 private final Integer theItemId;
57
58
59
60
61
62
63 PrometheusMapsItemId(final PrometheusDataItem pItem) {
64 theListKey = pItem.getItemType();
65 theItemId = pItem.getIndexedId();
66 }
67
68 @Override
69 public MetisFieldSetDef getDataFieldSet() {
70 return FIELD_DEFS;
71 }
72
73 @Override
74 public String formatObject(final OceanusDataFormatter pFormatter) {
75 return pFormatter.formatObject(theListKey) + ":" + theItemId;
76 }
77
78
79
80
81
82
83 private MetisListKey getListKey() {
84 return theListKey;
85 }
86
87
88
89
90
91
92 private Integer getItemId() {
93 return theItemId;
94 }
95
96 @Override
97 public boolean equals(final Object pThat) {
98 if (!(pThat instanceof PrometheusMapsItemId)) {
99 return false;
100 }
101 final PrometheusMapsItemId myThat = (PrometheusMapsItemId) pThat;
102 return theItemId.equals(myThat.getItemId())
103 && theListKey.equals(myThat.getListKey());
104 }
105
106 @Override
107 public int hashCode() {
108 return Objects.hash(theListKey, theItemId);
109 }
110 }