Skip to main content

easyofd_core/model/
custom_datas.rs

1//! OFD 自定义数据集合。
2//!
3//! 对应 Java: org.ofdrw.core.basicStructure.ofd.docInfo.CT_CustomDatas
4
5use crate::model::custom_data::CustomData;
6
7/// 自定义数据集合(ofd:CustomDatas)。
8///
9/// 对应 Java: ofdrw CT_CustomDatas。
10#[derive(Debug, Clone, PartialEq, Eq)]
11pub struct CustomDatas {
12    /// 自定义数据列表。
13    pub items: Vec<CustomData>,
14}
15
16impl CustomDatas {
17    /// 创建空集合。
18    pub fn new() -> Self {
19        Self { items: Vec::new() }
20    }
21
22    /// 添加自定义数据。
23    pub fn push(&mut self, data: CustomData) {
24        self.items.push(data);
25    }
26
27    /// 数量。
28    #[must_use]
29    pub fn len(&self) -> usize {
30        self.items.len()
31    }
32
33    /// 是否为空。
34    #[must_use]
35    pub fn is_empty(&self) -> bool {
36        self.items.is_empty()
37    }
38}
39
40impl Default for CustomDatas {
41    fn default() -> Self {
42        Self::new()
43    }
44}