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