use crate::{
Result, Rudof,
api::shacl::ShaclOperations,
formats::{ShaclFetchStrategy, ShaclValidationMode},
};
pub struct ValidateShaclBuilder<'a> {
rudof: &'a mut Rudof,
mode: Option<&'a ShaclValidationMode>,
fetch_strategy: Option<ShaclFetchStrategy>,
}
impl<'a> ValidateShaclBuilder<'a> {
pub(crate) fn new(rudof: &'a mut Rudof) -> Self {
Self {
rudof,
mode: None,
fetch_strategy: None,
}
}
pub fn with_shacl_validation_mode(mut self, mode: &'a ShaclValidationMode) -> Self {
self.mode = Some(mode);
self
}
pub fn with_fetch_strategy(mut self, strategy: ShaclFetchStrategy) -> Self {
self.fetch_strategy = Some(strategy);
self
}
pub fn execute(self) -> Result<()> {
match self.fetch_strategy {
None => <Rudof as ShaclOperations>::validate_shacl(self.rudof, self.mode),
Some(strategy) => {
crate::api::shacl::implementations::validate_shacl_with(self.rudof, self.mode, Some(strategy))
},
}
}
}