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