#[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 Unit {
    #[builder(default, into)]
    #[serde(rename = "name", skip_serializing_if = "Option::is_none", default)]
    name: Option<super::UnitName>,
    #[serde(rename = "symbol")]
    symbol: super::UnitSymbol,
    #[builder(default, into)]
    #[serde(rename = "property", skip_serializing_if = "Option::is_none", default)]
    property: Option<super::UnitProperty>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::UnitDimension>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "dimension", skip_serializing_if = "Option::is_none", default)]
    dimension: Option<Box<super::UnitDimension>>,
    #[serde(rename = "system")]
    system: super::UnitSystem,
}
impl Unit {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(symbol: super::UnitSymbol, system: super::UnitSystem) -> Self {
        Self::builder().symbol(symbol).system(system).build()
    }
    #[inline]
    pub fn name(&self) -> Option<&super::UnitName> {
        self.name.as_ref().map(|o| &*o)
    }
    #[inline]
    pub fn symbol(&self) -> &super::UnitSymbol {
        &self.symbol
    }
    /// Empty if no property is available. If two units measure different properties, it is not possible to
    /// convert between them.
    #[inline]
    pub fn property(&self) -> Option<&super::UnitProperty> {
        self.property.as_ref().map(|o| &*o)
    }
    /// The physical dimensions in terms of the base units of the system. It is only possible to convert units if
    /// they have the same dimension. Empty if the unit is a base unit.
    #[inline]
    pub fn dimension(&self) -> Option<&super::UnitDimension> {
        self.dimension.as_ref().map(|o| &**o)
    }
    #[inline]
    pub fn system(&self) -> &super::UnitSystem {
        &self.system
    }
}
