use crate::{Component, Severity, ShaclPath, ShaclRule, Target};
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(
deny_unknown_fields,
bound(
serialize = "Value: serde::Serialize, Count: serde::Serialize, Flags: serde::Serialize, Pattern: serde::Serialize",
deserialize = "Value: serde::Deserialize<'de>, Count: serde::Deserialize<'de>, Flags: serde::Deserialize<'de>, Pattern: serde::Deserialize<'de>"
)
)]
pub struct PropertyShape<Value = crate::DefaultTerm, Count = Value, Flags = Value, Pattern = Value>
{
pub id: Value,
pub path: ShaclPath,
pub path_node: Option<Value>,
pub targets: Vec<Target<Value>>,
pub components: Vec<Component<Value, Count, Flags, Pattern>>,
pub property_shapes: Vec<Value>,
pub deactivated: bool,
pub severity: Severity,
pub names: Vec<Value>,
pub descriptions: Vec<Value>,
pub order: Option<Value>,
pub default_value: Option<Value>,
pub messages: Vec<Value>,
pub rules: Vec<ShaclRule<Value>>,
}
impl<Value, Count, Flags, Pattern> PropertyShape<Value, Count, Flags, Pattern> {
#[must_use]
pub fn new(id: Value, path: ShaclPath) -> Self {
Self {
id,
path,
path_node: None,
targets: Vec::new(),
components: Vec::new(),
property_shapes: Vec::new(),
deactivated: false,
severity: Severity::default(),
names: Vec::new(),
descriptions: Vec::new(),
order: None,
default_value: None,
messages: Vec::new(),
rules: Vec::new(),
}
}
#[must_use]
pub fn with_component(mut self, component: Component<Value, Count, Flags, Pattern>) -> Self {
self.components.push(component);
self
}
#[must_use]
pub fn with_property_shape(mut self, shape: Value) -> Self {
self.property_shapes.push(shape);
self
}
#[must_use]
pub fn with_deactivated(mut self, deactivated: bool) -> Self {
self.deactivated = deactivated;
self
}
#[must_use]
pub fn with_severity(mut self, severity: Severity) -> Self {
self.severity = severity;
self
}
#[must_use]
pub fn with_name(mut self, name: Value) -> Self {
self.names.push(name);
self
}
#[must_use]
pub fn with_description(mut self, description: Value) -> Self {
self.descriptions.push(description);
self
}
#[must_use]
pub fn with_order(mut self, order: Value) -> Self {
self.order = Some(order);
self
}
#[must_use]
pub fn with_default_value(mut self, value: Value) -> Self {
self.default_value = Some(value);
self
}
#[must_use]
pub fn with_message(mut self, message: Value) -> Self {
self.messages.push(message);
self
}
#[must_use]
pub fn with_target(mut self, target: Target<Value>) -> Self {
self.targets.push(target);
self
}
#[must_use]
pub fn with_rule(mut self, rule: ShaclRule<Value>) -> Self {
self.rules.push(rule);
self
}
#[must_use]
pub fn path_display(&self) -> String {
self.path.to_string()
}
}