#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash
)]
#[serde(crate = "conjure_object::serde")]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct SortOptions {
    #[serde(rename = "isDescending")]
    is_descending: bool,
    #[builder(default, into)]
    #[serde(rename = "field", skip_serializing_if = "Option::is_none", default)]
    field: Option<super::SortField>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::SortKey>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "sortKey", skip_serializing_if = "Option::is_none", default)]
    sort_key: Option<Box<super::SortKey>>,
    #[builder(default, into)]
    #[serde(
        rename = "additionalSortKeys",
        skip_serializing_if = "Option::is_none",
        default
    )]
    additional_sort_keys: Option<Vec<super::SortKeyWithDirection>>,
}
impl SortOptions {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(is_descending: bool) -> Self {
        Self::builder().is_descending(is_descending).build()
    }
    #[inline]
    pub fn is_descending(&self) -> bool {
        self.is_descending
    }
    #[deprecated(note = "use SortKey with SortField union type instead")]
    #[inline]
    pub fn field(&self) -> Option<&super::SortField> {
        self.field.as_ref().map(|o| &*o)
    }
    /// Field to sort by. Includes both field and property-based sorting.
    #[inline]
    pub fn sort_key(&self) -> Option<&super::SortKey> {
        self.sort_key.as_ref().map(|o| &**o)
    }
    /// Optional secondary sort keys for tiebreaking. Applied in order after the primary sortKey.
    /// Each entry specifies its own sort key and direction. If empty or absent, ties are broken by UUID only.
    #[inline]
    pub fn additional_sort_keys(&self) -> Option<&[super::SortKeyWithDirection]> {
        self.additional_sort_keys.as_ref().map(|o| &**o)
    }
}
