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 javax.xml.namespace.QName;
9   
10  public interface IFlagInstance extends IFlag, IValuedInstance, IInstanceAbsolute {
11  
12    boolean DEFAULT_FLAG_REQUIRED = false;
13  
14    @Override
15    IModelDefinition getParentContainer();
16  
17    @Override
18    IFlagDefinition getDefinition();
19  
20    @Override
21    default IModelDefinition getContainingDefinition() {
22      return getParentContainer();
23    }
24  
25    /**
26     * Determines if a flag value is required to be provided.
27     *
28     * @return {@code true} if a value is required, or {@code false} otherwise
29     * @see #DEFAULT_FLAG_REQUIRED
30     */
31    default boolean isRequired() {
32      return DEFAULT_FLAG_REQUIRED;
33    }
34  
35    @Override
36    default QName getReferencedDefinitionQName() {
37      return getContainingModule().toFlagQName(getName());
38    }
39  
40    @Override
41    default QName getXmlQName() {
42      // flags do not have a namespace by default
43      return getContainingModule().toFlagQName(getEffectiveName());
44    }
45  }