use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
pub struct ContextAnnotations {
#[serde(skip_serializing_if = "Option::is_none")]
pub domain: Option<Domain>,
#[serde(skip_serializing_if = "Option::is_none")]
pub entity: Option<Entity>,
#[serde(flatten)]
pub extra: std::collections::HashMap<String, serde_json::Value>,
}
impl ContextAnnotations {
pub fn is_empty_extra(&self) -> bool {
let res = self.extra.is_empty()
&& self
.domain
.as_ref()
.map(|it| it.is_empty_extra())
.unwrap_or(true)
&& self
.entity
.as_ref()
.map(|it| it.is_empty_extra())
.unwrap_or(true);
if !res {
println!("ContextAnnotations {:?}", self.extra);
}
res
}
}
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
pub struct Domain {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(flatten)]
pub extra: std::collections::HashMap<String, serde_json::Value>,
}
impl Domain {
pub fn is_empty_extra(&self) -> bool {
let res = self.extra.is_empty();
if !res {
println!("Domain {:?}", self.extra);
}
res
}
}
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
pub struct Entity {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(flatten)]
pub extra: std::collections::HashMap<String, serde_json::Value>,
}
impl Entity {
pub fn is_empty_extra(&self) -> bool {
let res = self.extra.is_empty();
if !res {
println!("Entity {:?}", self.extra);
}
res
}
}