Skip to main content

nominal_api_conjure/conjure/objects/api/
numeric_property_range_predicate.rs

1/// Inclusive range on a numeric property. At least one bound is required.
2/// BETWEEN: min <= x <= max. An absent bound is unbounded on that side.
3/// NOT_BETWEEN: x < min OR x > max. An absent bound drops that side.
4/// Both operators require a numeric value for `name`. Missing properties
5/// and string values never match.
6/// Bounds are closed [min, max] to match the number chip (is between /
7/// is not between), not half-open.
8#[derive(
9    Debug,
10    Clone,
11    conjure_object::serde::Serialize,
12    conjure_object::serde::Deserialize,
13    conjure_object::private::DeriveWith
14)]
15#[serde(crate = "conjure_object::serde")]
16#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
17#[conjure_object::private::staged_builder::staged_builder]
18#[builder(crate = conjure_object::private::staged_builder, update, inline)]
19pub struct NumericPropertyRangePredicate {
20    #[serde(rename = "name")]
21    name: super::PropertyName,
22    #[builder(default, into)]
23    #[serde(rename = "min", skip_serializing_if = "Option::is_none", default)]
24    #[derive_with(with = conjure_object::private::DoubleWrapper)]
25    min: Option<f64>,
26    #[builder(default, into)]
27    #[serde(rename = "max", skip_serializing_if = "Option::is_none", default)]
28    #[derive_with(with = conjure_object::private::DoubleWrapper)]
29    max: Option<f64>,
30    #[serde(rename = "operator")]
31    operator: super::NumericPropertyRangeOperator,
32}
33impl NumericPropertyRangePredicate {
34    /// Constructs a new instance of the type.
35    #[inline]
36    pub fn new(
37        name: super::PropertyName,
38        operator: super::NumericPropertyRangeOperator,
39    ) -> Self {
40        Self::builder().name(name).operator(operator).build()
41    }
42    #[inline]
43    pub fn name(&self) -> &super::PropertyName {
44        &self.name
45    }
46    #[inline]
47    pub fn min(&self) -> Option<f64> {
48        self.min.as_ref().map(|o| *o)
49    }
50    #[inline]
51    pub fn max(&self) -> Option<f64> {
52        self.max.as_ref().map(|o| *o)
53    }
54    #[inline]
55    pub fn operator(&self) -> &super::NumericPropertyRangeOperator {
56        &self.operator
57    }
58}