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