/// Every range aggregation must be defined by a data scope and set of conditions. This type should be used by
/// every comparison workbook viz definition.
#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct RangeAggregationDefinition {
    #[builder(custom(type = super::ComparisonWorkbookDataScope, convert = Box::new))]
    #[serde(rename = "dataScope")]
    data_scope: Box<super::ComparisonWorkbookDataScope>,
    #[builder(custom(type = super::ComputeNodeWithContext, convert = Box::new))]
    #[serde(rename = "condition")]
    condition: Box<super::ComputeNodeWithContext>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::TimeWindow>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "timeWindow", skip_serializing_if = "Option::is_none", default)]
    time_window: Option<Box<super::TimeWindow>>,
}
impl RangeAggregationDefinition {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        data_scope: super::ComparisonWorkbookDataScope,
        condition: super::ComputeNodeWithContext,
    ) -> Self {
        Self::builder().data_scope(data_scope).condition(condition).build()
    }
    #[inline]
    pub fn data_scope(&self) -> &super::ComparisonWorkbookDataScope {
        &*self.data_scope
    }
    #[inline]
    pub fn condition(&self) -> &super::ComputeNodeWithContext {
        &*self.condition
    }
    /// determines the window of data included in the visualization. Currently only applied on assets.
    #[inline]
    pub fn time_window(&self) -> Option<&super::TimeWindow> {
        self.time_window.as_ref().map(|o| &**o)
    }
}
