1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.databind.io.xml;
7   
8   import org.w3c.dom.Element;
9   
10  import java.util.Collections;
11  import java.util.List;
12  
13  import dev.metaschema.core.model.IAnyContent;
14  import edu.umd.cs.findbugs.annotations.NonNull;
15  
16  /**
17   * XML-specific implementation of {@link IAnyContent} that stores captured
18   * unmodeled content as W3C DOM {@link Element} instances.
19   */
20  public class XmlAnyContent implements IAnyContent {
21    @NonNull
22    private final List<Element> elements;
23  
24    /**
25     * Construct a new instance with the provided captured elements.
26     *
27     * @param elements
28     *          the captured DOM elements, must not be null
29     */
30    public XmlAnyContent(@NonNull List<Element> elements) {
31      this.elements = Collections.unmodifiableList(List.copyOf(elements));
32    }
33  
34    @Override
35    public boolean isEmpty() {
36      return elements.isEmpty();
37    }
38  
39    /**
40     * Get the captured DOM elements.
41     *
42     * @return an unmodifiable list of captured elements
43     */
44    @NonNull
45    public List<Element> getElements() {
46      return elements;
47    }
48  }