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