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