1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.databind.io.json;
7   
8   import com.fasterxml.jackson.databind.node.ObjectNode;
9   
10  import dev.metaschema.core.model.IAnyContent;
11  import edu.umd.cs.findbugs.annotations.NonNull;
12  
13  /**
14   * JSON/YAML-specific implementation of {@link IAnyContent} that stores captured
15   * unmodeled content as a Jackson {@link ObjectNode}.
16   */
17  public class JsonAnyContent implements IAnyContent {
18    @NonNull
19    private final ObjectNode properties;
20  
21    /**
22     * Construct a new instance with the provided captured properties.
23     *
24     * @param properties
25     *          the captured JSON properties, must not be null
26     */
27    public JsonAnyContent(@NonNull ObjectNode properties) {
28      this.properties = properties;
29    }
30  
31    @Override
32    public boolean isEmpty() {
33      return properties.isEmpty();
34    }
35  
36    /**
37     * Get the captured JSON properties.
38     *
39     * @return the captured ObjectNode
40     */
41    @NonNull
42    public ObjectNode getProperties() {
43      return properties;
44    }
45  }