/// A single bucket in a bucketed frequency domain plot.
#[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 FrequencyBucket {
    #[serde(rename = "frequencyStart")]
    #[derive_with(with = conjure_object::private::DoubleWrapper)]
    frequency_start: f64,
    #[serde(rename = "frequencyEnd")]
    #[derive_with(with = conjure_object::private::DoubleWrapper)]
    frequency_end: f64,
    #[serde(rename = "frequencyCenter")]
    #[derive_with(with = conjure_object::private::DoubleWrapper)]
    frequency_center: f64,
    #[serde(rename = "minAmplitude")]
    #[derive_with(with = conjure_object::private::DoubleWrapper)]
    min_amplitude: f64,
    #[serde(rename = "maxAmplitude")]
    #[derive_with(with = conjure_object::private::DoubleWrapper)]
    max_amplitude: f64,
    #[serde(rename = "meanAmplitude")]
    #[derive_with(with = conjure_object::private::DoubleWrapper)]
    mean_amplitude: f64,
    #[serde(rename = "count")]
    count: conjure_object::SafeLong,
    #[builder(custom(type = super::FrequencyPoint, convert = Box::new))]
    #[serde(rename = "firstPoint")]
    first_point: Box<super::FrequencyPoint>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::FrequencyPoint>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "lastPoint", skip_serializing_if = "Option::is_none", default)]
    last_point: Option<Box<super::FrequencyPoint>>,
}
impl FrequencyBucket {
    /// The start frequency of this bucket (inclusive).
    #[inline]
    pub fn frequency_start(&self) -> f64 {
        self.frequency_start
    }
    /// The end frequency of this bucket (exclusive).
    #[inline]
    pub fn frequency_end(&self) -> f64 {
        self.frequency_end
    }
    /// The center frequency of this bucket.
    #[inline]
    pub fn frequency_center(&self) -> f64 {
        self.frequency_center
    }
    /// The minimum amplitude value in this bucket.
    #[inline]
    pub fn min_amplitude(&self) -> f64 {
        self.min_amplitude
    }
    /// The maximum amplitude value in this bucket.
    #[inline]
    pub fn max_amplitude(&self) -> f64 {
        self.max_amplitude
    }
    /// The mean amplitude value in this bucket.
    #[inline]
    pub fn mean_amplitude(&self) -> f64 {
        self.mean_amplitude
    }
    /// The number of original frequency points that were aggregated into this bucket.
    #[inline]
    pub fn count(&self) -> conjure_object::SafeLong {
        self.count
    }
    /// The first point (lowest frequency) in this bucket.
    #[inline]
    pub fn first_point(&self) -> &super::FrequencyPoint {
        &*self.first_point
    }
    /// The last point (highest frequency) in this bucket. Will be empty if the bucket only has a single point.
    #[inline]
    pub fn last_point(&self) -> Option<&super::FrequencyPoint> {
        self.last_point.as_ref().map(|o| &**o)
    }
}
