1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.prometheus.validate;
18
19 import io.github.tonywasher.joceanus.prometheus.data.PrometheusData.PrometheusDataItemCtl;
20 import io.github.tonywasher.joceanus.prometheus.data.PrometheusData.PrometheusDataValidator;
21 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataInfoItem;
22 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataItem;
23 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataResource;
24 import io.github.tonywasher.joceanus.prometheus.data.PrometheusStaticDataItem;
25
26
27
28
29 public class PrometheusValidateInfo
30 implements PrometheusDataValidator {
31
32
33
34 public PrometheusValidateInfo() {
35
36 }
37
38 @Override
39 public void validate(final PrometheusDataItemCtl pInfo) {
40 final PrometheusDataInfoItem myInfo = (PrometheusDataInfoItem) pInfo;
41 final PrometheusStaticDataItem myType = myInfo.getInfoType();
42 final PrometheusDataItem myOwner = myInfo.getOwner();
43 final Object myValue = myInfo.getValue(Object.class);
44
45
46 if (myType == null) {
47 myInfo.addError(PrometheusDataItem.ERROR_MISSING, PrometheusDataResource.DATAINFO_TYPE);
48 }
49
50
51 if (myOwner == null) {
52 myInfo.addError(PrometheusDataItem.ERROR_MISSING, PrometheusDataResource.DATAINFO_OWNER);
53 }
54
55
56 if (myValue == null) {
57 myInfo.addError(PrometheusDataItem.ERROR_MISSING, PrometheusDataResource.DATAINFO_VALUE);
58 }
59
60
61 if (!myInfo.hasErrors()) {
62 myInfo.setValidEdit();
63 }
64 }
65 }