1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.schemagen.json.impl;
7   
8   import com.fasterxml.jackson.databind.node.ObjectNode;
9   
10  import edu.umd.cs.findbugs.annotations.NonNull;
11  
12  /**
13   * Represents a JSON schema for a given Metaschema-based model object, which may
14   * be part of a larger JSON schema.
15   */
16  public interface IJsonSchema {
17  
18    /**
19     * Generate an inline JSON schema.
20     *
21     * @param node
22     *          the property JSON object
23     * @param state
24     *          the schema generation state used for context
25     */
26    void generateInlineJsonSchema(@NonNull ObjectNode node, @NonNull IJsonGenerationState state);
27  
28    /**
29     * Generate a JSON schema or a reference to a JSON schema definition.
30     * <p>
31     * This method will determine if this schema is intended to be inline or used as
32     * a JSON schema definition by reference.
33     *
34     * @param node
35     *          the property JSON object
36     * @param state
37     *          the schema generation state used for context
38     */
39    default void generateJsonSchemaOrDefinitionRef(@NonNull ObjectNode node, @NonNull IJsonGenerationState state) {
40      generateInlineJsonSchema(node, state);
41    }
42  
43    /**
44     * Determine if the schema is defined inline or as a global definition.
45     *
46     * @param state
47     *          the schema generation state used for context
48     * @return {@code true} if the schema is to be defined inline or {@code false}
49     *         if the schema is to be defined globally
50     */
51    default boolean isInline(@NonNull IJsonGenerationState state) {
52      return true;
53    }
54  }