#[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 ComputeNodeWithContext {
    #[builder(
        custom(type = super::super::super::compute::api::ComputeNode, convert = Box::new)
    )]
    #[serde(rename = "computeNode")]
    compute_node: Box<super::super::super::compute::api::ComputeNode>,
    #[builder(custom(type = super::ComparisonWorkbookContext, convert = Box::new))]
    #[serde(rename = "context")]
    context: Box<super::ComparisonWorkbookContext>,
    #[builder(
        custom(type = super::SupplementalComparisonWorkbookContext, convert = Box::new)
    )]
    #[serde(rename = "supplementalContext")]
    supplemental_context: Box<super::SupplementalComparisonWorkbookContext>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::super::super::channelvariables::api::ChannelVariableComputeExpression>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(
        rename = "computeExpression",
        skip_serializing_if = "Option::is_none",
        default
    )]
    compute_expression: Option<
        Box<super::super::super::channelvariables::api::ChannelVariableComputeExpression>,
    >,
}
impl ComputeNodeWithContext {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(
        compute_node: super::super::super::compute::api::ComputeNode,
        context: super::ComparisonWorkbookContext,
        supplemental_context: super::SupplementalComparisonWorkbookContext,
    ) -> Self {
        Self::builder()
            .compute_node(compute_node)
            .context(context)
            .supplemental_context(supplemental_context)
            .build()
    }
    /// Graph representation of the compute for a variable.
    #[inline]
    pub fn compute_node(&self) -> &super::super::super::compute::api::ComputeNode {
        &*self.compute_node
    }
    #[inline]
    pub fn context(&self) -> &super::ComparisonWorkbookContext {
        &*self.context
    }
    #[deprecated(note = "migrated into visualization definitions.")]
    #[inline]
    pub fn supplemental_context(&self) -> &super::SupplementalComparisonWorkbookContext {
        &*self.supplemental_context
    }
    /// Code representation of the compute for a variable. Should be equivalent to the computeNode.
    #[inline]
    pub fn compute_expression(
        &self,
    ) -> Option<
        &super::super::super::channelvariables::api::ChannelVariableComputeExpression,
    > {
        self.compute_expression.as_ref().map(|o| &**o)
    }
}
