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.DefaultIndexHasKeyConstraint;
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 public interface IIndexHasKeyConstraint extends IKeyConstraint {
19
20
21
22
23
24 @NonNull
25 String getIndexName();
26
27 @Override
28 default <T, R> R accept(IConstraintVisitor<T, R> visitor, T state) {
29 return visitor.visitIndexHasKeyConstraint(this, state);
30 }
31
32
33
34
35
36
37
38
39 @NonNull
40 static Builder builder(@NonNull String useIndex) {
41 return new Builder(useIndex);
42 }
43
44
45
46
47
48 final class Builder
49 extends AbstractKeyConstraintBuilder<Builder, IIndexHasKeyConstraint> {
50 @NonNull
51 private final String indexName;
52
53 private Builder(@NonNull String useIndex) {
54 this.indexName = useIndex;
55 }
56
57 @Override
58 protected Builder getThis() {
59 return this;
60 }
61
62 @NonNull
63 private String getIndexName() {
64 return indexName;
65 }
66
67 @Override
68 protected IIndexHasKeyConstraint newInstance() {
69 return new DefaultIndexHasKeyConstraint(
70 getId(),
71 getFormalName(),
72 getDescription(),
73 ObjectUtils.notNull(getSource()),
74 getLevel(),
75 getTarget(),
76 getProperties(),
77 getIndexName(),
78 getKeyFields(),
79 getMessage(),
80 getRemarks());
81 }
82 }
83 }