1
2
3
4
5
6 package dev.metaschema.core.model.constraint;
7
8 import dev.metaschema.core.model.constraint.impl.DefaultIndexConstraint;
9 import dev.metaschema.core.util.ObjectUtils;
10 import edu.umd.cs.findbugs.annotations.NonNull;
11
12
13
14
15
16
17
18
19 public interface IIndexConstraint extends IKeyConstraint {
20 @Override
21 default Type getType() {
22 return Type.INDEX;
23 }
24
25
26
27
28
29
30
31 @NonNull
32 String getName();
33
34 @Override
35 default <T, R> R accept(IConstraintVisitor<T, R> visitor, T state) {
36 return visitor.visitIndexConstraint(this, state);
37 }
38
39
40
41
42
43
44
45
46
47 @NonNull
48 static Builder builder(@NonNull String name) {
49 return new Builder(name);
50 }
51
52
53
54
55 final class Builder
56 extends AbstractKeyConstraintBuilder<Builder, IIndexConstraint> {
57 @NonNull
58 private final String name;
59
60 private Builder(@NonNull String name) {
61
62 this.name = name;
63 }
64
65 @Override
66 protected Builder getThis() {
67 return this;
68 }
69
70 @NonNull
71 private String getName() {
72 return name;
73 }
74
75 @Override
76 protected DefaultIndexConstraint newInstance() {
77 return new DefaultIndexConstraint(
78 getId(),
79 getFormalName(),
80 getDescription(),
81 ObjectUtils.notNull(getSource()),
82 getLevel(),
83 getTarget(),
84 getProperties(),
85 getName(),
86 getKeyFields(),
87 getMessage(),
88 getRemarks());
89 }
90 }
91 }