1
2
3
4
5
6 package gov.nist.secauto.metaschema.core.model.constraint;
7
8 import gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultExpectConstraint;
9 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
10
11 import edu.umd.cs.findbugs.annotations.NonNull;
12
13
14
15
16
17
18
19 public interface IExpectConstraint extends IConfigurableMessageConstraint {
20
21
22
23
24
25 @NonNull
26 String getTest();
27
28 @Override
29 default <T, R> R accept(IConstraintVisitor<T, R> visitor, T state) {
30 return visitor.visitExpectConstraint(this, state);
31 }
32
33
34
35
36
37
38 @NonNull
39 static Builder builder() {
40 return new Builder();
41 }
42
43
44
45
46 final class Builder
47 extends AbstractConfigurableMessageConstraintBuilder<Builder, IExpectConstraint> {
48 private String test;
49
50 private Builder() {
51
52 }
53
54
55
56
57
58
59
60
61 @NonNull
62 public Builder test(@NonNull String test) {
63 this.test = test;
64 return this;
65 }
66
67 @Override
68 protected Builder getThis() {
69 return this;
70 }
71
72 @Override
73 protected void validate() {
74 super.validate();
75
76 ObjectUtils.requireNonNull(getTest());
77 }
78
79 private String getTest() {
80 return test;
81 }
82
83 @Override
84 protected IExpectConstraint newInstance() {
85 return new DefaultExpectConstraint(
86 getId(),
87 getFormalName(),
88 getDescription(),
89 ObjectUtils.notNull(getSource()),
90 getLevel(),
91 getTarget(),
92 getProperties(),
93 ObjectUtils.requireNonNull(getTest()),
94 getMessage(),
95 getRemarks());
96 }
97 }
98 }