shacl_ir/components/max_count.rs
1use std::fmt::Display;
2
3/// sh:maxCount specifies the maximum number of value nodes that satisfy the
4/// condition.
5///
6/// - IRI: https://www.w3.org/TR/shacl/#MaxCountConstraintComponent
7/// - DEF: If the number of value nodes is greater than $maxCount, there is a
8/// validation result.
9#[derive(Debug, Clone)]
10pub struct MaxCount {
11 max_count: usize,
12}
13
14impl MaxCount {
15 pub fn new(max_count: isize) -> Self {
16 MaxCount {
17 max_count: max_count as usize,
18 }
19 }
20
21 pub fn max_count(&self) -> usize {
22 self.max_count
23 }
24}
25
26impl Display for MaxCount {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 write!(f, "MaxCount: {}", self.max_count())
29 }
30}