1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.core.model;
7
8 import edu.umd.cs.findbugs.annotations.NonNull;
9
10 /**
11 * Represents a flag instance within a field or assembly definition.
12 * <p>
13 * A flag instance references a flag definition and specifies how that flag is
14 * used within its containing definition, including whether the flag is
15 * required.
16 */
17 public interface IFlagInstance extends IFlag, IValuedInstance, IInstanceAbsolute {
18
19 /**
20 * The default value for whether a flag is required.
21 */
22 boolean DEFAULT_FLAG_REQUIRED = false;
23
24 /**
25 * Retrieves the parent container that contains this flag instance.
26 *
27 * @return the parent model definition
28 */
29 @Override
30 IModelDefinition getParentContainer();
31
32 /**
33 * Retrieves the flag definition referenced by this instance.
34 *
35 * @return the flag definition
36 */
37 @Override
38 IFlagDefinition getDefinition();
39
40 @Override
41 default IModelDefinition getContainingDefinition() {
42 return getParentContainer();
43 }
44
45 /**
46 * Determines if a flag value is required to be provided.
47 *
48 * @return {@code true} if a value is required, or {@code false} otherwise
49 * @see #DEFAULT_FLAG_REQUIRED
50 */
51 default boolean isRequired() {
52 return DEFAULT_FLAG_REQUIRED;
53 }
54
55 /**
56 * A visitor callback.
57 *
58 * @param <CONTEXT>
59 * the type of the context parameter
60 * @param <RESULT>
61 * the type of the visitor result
62 * @param visitor
63 * the calling visitor
64 * @param context
65 * a parameter used to pass contextual information between visitors
66 * @return the visitor result
67 */
68 @Override
69 default <CONTEXT, RESULT> RESULT accept(@NonNull IModelElementVisitor<CONTEXT, RESULT> visitor, CONTEXT context) {
70 return visitor.visitFlagInstance(this, context);
71 }
72 }