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 final class Builder
45 extends AbstractKeyConstraintBuilder<Builder, IIndexHasKeyConstraint> {
46 @NonNull
47 private final String indexName;
48
49 private Builder(@NonNull String useIndex) {
50 this.indexName = useIndex;
51 }
52
53 @Override
54 protected Builder getThis() {
55 return this;
56 }
57
58 @NonNull
59 private String getIndexName() {
60 return indexName;
61 }
62
63 @Override
64 protected IIndexHasKeyConstraint newInstance() {
65 return new DefaultIndexHasKeyConstraint(
66 getId(),
67 getFormalName(),
68 getDescription(),
69 ObjectUtils.notNull(getSource()),
70 getLevel(),
71 getTarget(),
72 getProperties(),
73 getIndexName(),
74 getKeyFields(),
75 getRemarks());
76 }
77 }
78 }