use rdf_syntax::Iri;
use crate::{
algorithms::expansion::JsonLdExpansionOptions,
context::{JsonLdProcessedTermDefinitionRef, RawJsonLdProcessedContext},
};
pub(crate) struct Expander<'a> {
pub base_url: Option<&'a Iri>,
pub options: JsonLdExpansionOptions,
pub active_context: &'a RawJsonLdProcessedContext,
pub active_property: Option<&'a str>,
}
impl<'a> Expander<'a> {
pub fn active_property_definition(&self) -> Option<JsonLdProcessedTermDefinitionRef<'_>> {
self.active_property
.and_then(|t| self.active_context.get(t))
}
pub fn with_active_context<'b>(
&'b self,
active_context: &'b RawJsonLdProcessedContext,
) -> Expander<'b> {
Expander {
base_url: self.base_url,
options: self.options,
active_context,
active_property: self.active_property,
}
}
pub fn with_active_property<'b>(&'b self, active_property: Option<&'b str>) -> Expander<'b> {
Expander {
base_url: self.base_url,
options: self.options,
active_context: self.active_context,
active_property,
}
}
pub fn with_active_context_and_property<'b>(
&'b self,
active_context: &'b RawJsonLdProcessedContext,
active_property: Option<&'b str>,
) -> Expander<'b> {
Expander {
base_url: self.base_url,
options: self.options,
active_context,
active_property,
}
}
}