001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.databind.io.xml; 007 008import org.w3c.dom.Element; 009 010import java.util.Collections; 011import java.util.List; 012 013import dev.metaschema.core.model.IAnyContent; 014import edu.umd.cs.findbugs.annotations.NonNull; 015 016/** 017 * XML-specific implementation of {@link IAnyContent} that stores captured 018 * unmodeled content as W3C DOM {@link Element} instances. 019 */ 020public class XmlAnyContent implements IAnyContent { 021 @NonNull 022 private final List<Element> elements; 023 024 /** 025 * Construct a new instance with the provided captured elements. 026 * 027 * @param elements 028 * the captured DOM elements, must not be null 029 */ 030 public XmlAnyContent(@NonNull List<Element> elements) { 031 this.elements = Collections.unmodifiableList(List.copyOf(elements)); 032 } 033 034 @Override 035 public boolean isEmpty() { 036 return elements.isEmpty(); 037 } 038 039 /** 040 * Get the captured DOM elements. 041 * 042 * @return an unmodifiable list of captured elements 043 */ 044 @NonNull 045 public List<Element> getElements() { 046 return elements; 047 } 048}