// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: dev.sensorthings.datastream
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::dev_sensorthings::datastream;
/// Groups Observations of one ObservedProperty by one Sensor on one Thing. Carries all context needed to interpret observation results.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Datastream<'a> {
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///O&M observation type URI, e.g. http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement
    #[serde(borrow)]
    pub observation_type: UriValue<'a>,
    ///Representative location for the datastream
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub observed_area: Option<Data<'a>>,
    ///AT-URI of the dev.sensorthings.observedProperty record
    #[serde(borrow)]
    pub observed_property: AtUri<'a>,
    ///10^n divisor for numeric results. E.g. 2 means observation integers are in centi-units (÷100). Default 0. Only meaningful for numericResult and arrayResult types.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result_scale_factor: Option<i64>,
    ///AT-URI of the dev.sensorthings.sensor record
    #[serde(borrow)]
    pub sensor: AtUri<'a>,
    ///AT-URI of the dev.sensorthings.thing record
    #[serde(borrow)]
    pub thing: AtUri<'a>,
    #[serde(borrow)]
    pub unit_of_measurement: datastream::UnitOfMeasurement<'a>,
    ///Vertical datum reference for water level or elevation measurements. Either a URI (e.g. http://www.opengis.net/def/crs/EPSG/0/5731 for Malin Head) or a human-readable identifier (e.g. 'Chart Datum', 'local-gauge-zero'). Absent for non-vertical measurements.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub vertical_datum: Option<CowStr<'a>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct DatastreamGetRecordOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub value: Datastream<'a>,
}

/// UCUM-compatible unit description.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct UnitOfMeasurement<'a> {
    ///URI from QUDT, UCUM, or similar unit ontology
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub definition: Option<UriValue<'a>>,
    #[serde(borrow)]
    pub name: CowStr<'a>,
    #[serde(borrow)]
    pub symbol: CowStr<'a>,
}

impl<'a> Datastream<'a> {
    pub fn uri(
        uri: impl Into<CowStr<'a>>,
    ) -> Result<RecordUri<'a, DatastreamRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct DatastreamRecord;
impl XrpcResp for DatastreamRecord {
    const NSID: &'static str = "dev.sensorthings.datastream";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = DatastreamGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

impl From<DatastreamGetRecordOutput<'_>> for Datastream<'_> {
    fn from(output: DatastreamGetRecordOutput<'_>) -> Self {
        use jacquard_common::IntoStatic;
        output.value.into_static()
    }
}

impl Collection for Datastream<'_> {
    const NSID: &'static str = "dev.sensorthings.datastream";
    type Record = DatastreamRecord;
}

impl Collection for DatastreamRecord {
    const NSID: &'static str = "dev.sensorthings.datastream";
    type Record = DatastreamRecord;
}

impl<'a> LexiconSchema for Datastream<'a> {
    fn nsid() -> &'static str {
        "dev.sensorthings.datastream"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_dev_sensorthings_datastream()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2048usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 2048usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.vertical_datum {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("vertical_datum"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for UnitOfMeasurement<'a> {
    fn nsid() -> &'static str {
        "dev.sensorthings.datastream"
    }
    fn def_name() -> &'static str {
        "unitOfMeasurement"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_dev_sensorthings_datastream()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.symbol;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("symbol"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

pub mod datastream_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type ObservationType;
        type ObservedProperty;
        type CreatedAt;
        type Sensor;
        type UnitOfMeasurement;
        type Name;
        type Thing;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ObservationType = Unset;
        type ObservedProperty = Unset;
        type CreatedAt = Unset;
        type Sensor = Unset;
        type UnitOfMeasurement = Unset;
        type Name = Unset;
        type Thing = Unset;
    }
    ///State transition - sets the `observation_type` field to Set
    pub struct SetObservationType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetObservationType<S> {}
    impl<S: State> State for SetObservationType<S> {
        type ObservationType = Set<members::observation_type>;
        type ObservedProperty = S::ObservedProperty;
        type CreatedAt = S::CreatedAt;
        type Sensor = S::Sensor;
        type UnitOfMeasurement = S::UnitOfMeasurement;
        type Name = S::Name;
        type Thing = S::Thing;
    }
    ///State transition - sets the `observed_property` field to Set
    pub struct SetObservedProperty<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetObservedProperty<S> {}
    impl<S: State> State for SetObservedProperty<S> {
        type ObservationType = S::ObservationType;
        type ObservedProperty = Set<members::observed_property>;
        type CreatedAt = S::CreatedAt;
        type Sensor = S::Sensor;
        type UnitOfMeasurement = S::UnitOfMeasurement;
        type Name = S::Name;
        type Thing = S::Thing;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type ObservationType = S::ObservationType;
        type ObservedProperty = S::ObservedProperty;
        type CreatedAt = Set<members::created_at>;
        type Sensor = S::Sensor;
        type UnitOfMeasurement = S::UnitOfMeasurement;
        type Name = S::Name;
        type Thing = S::Thing;
    }
    ///State transition - sets the `sensor` field to Set
    pub struct SetSensor<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSensor<S> {}
    impl<S: State> State for SetSensor<S> {
        type ObservationType = S::ObservationType;
        type ObservedProperty = S::ObservedProperty;
        type CreatedAt = S::CreatedAt;
        type Sensor = Set<members::sensor>;
        type UnitOfMeasurement = S::UnitOfMeasurement;
        type Name = S::Name;
        type Thing = S::Thing;
    }
    ///State transition - sets the `unit_of_measurement` field to Set
    pub struct SetUnitOfMeasurement<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUnitOfMeasurement<S> {}
    impl<S: State> State for SetUnitOfMeasurement<S> {
        type ObservationType = S::ObservationType;
        type ObservedProperty = S::ObservedProperty;
        type CreatedAt = S::CreatedAt;
        type Sensor = S::Sensor;
        type UnitOfMeasurement = Set<members::unit_of_measurement>;
        type Name = S::Name;
        type Thing = S::Thing;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type ObservationType = S::ObservationType;
        type ObservedProperty = S::ObservedProperty;
        type CreatedAt = S::CreatedAt;
        type Sensor = S::Sensor;
        type UnitOfMeasurement = S::UnitOfMeasurement;
        type Name = Set<members::name>;
        type Thing = S::Thing;
    }
    ///State transition - sets the `thing` field to Set
    pub struct SetThing<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetThing<S> {}
    impl<S: State> State for SetThing<S> {
        type ObservationType = S::ObservationType;
        type ObservedProperty = S::ObservedProperty;
        type CreatedAt = S::CreatedAt;
        type Sensor = S::Sensor;
        type UnitOfMeasurement = S::UnitOfMeasurement;
        type Name = S::Name;
        type Thing = Set<members::thing>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `observation_type` field
        pub struct observation_type(());
        ///Marker type for the `observed_property` field
        pub struct observed_property(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `sensor` field
        pub struct sensor(());
        ///Marker type for the `unit_of_measurement` field
        pub struct unit_of_measurement(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `thing` field
        pub struct thing(());
    }
}

/// Builder for constructing an instance of this type
pub struct DatastreamBuilder<'a, S: datastream_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<Data<'a>>,
        Option<AtUri<'a>>,
        Option<i64>,
        Option<AtUri<'a>>,
        Option<AtUri<'a>>,
        Option<datastream::UnitOfMeasurement<'a>>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Datastream<'a> {
    /// Create a new builder for this type
    pub fn new() -> DatastreamBuilder<'a, datastream_state::Empty> {
        DatastreamBuilder::new()
    }
}

impl<'a> DatastreamBuilder<'a, datastream_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        DatastreamBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::CreatedAt: datastream_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> DatastreamBuilder<'a, datastream_state::SetCreatedAt<S>> {
        self._fields.0 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: datastream_state::State> DatastreamBuilder<'a, S> {
    /// Set the `description` field (optional)
    pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `description` field to an Option value (optional)
    pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::Name: datastream_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> DatastreamBuilder<'a, datastream_state::SetName<S>> {
        self._fields.2 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::ObservationType: datastream_state::IsUnset,
{
    /// Set the `observationType` field (required)
    pub fn observation_type(
        mut self,
        value: impl Into<UriValue<'a>>,
    ) -> DatastreamBuilder<'a, datastream_state::SetObservationType<S>> {
        self._fields.3 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: datastream_state::State> DatastreamBuilder<'a, S> {
    /// Set the `observedArea` field (optional)
    pub fn observed_area(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `observedArea` field to an Option value (optional)
    pub fn maybe_observed_area(mut self, value: Option<Data<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::ObservedProperty: datastream_state::IsUnset,
{
    /// Set the `observedProperty` field (required)
    pub fn observed_property(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> DatastreamBuilder<'a, datastream_state::SetObservedProperty<S>> {
        self._fields.5 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: datastream_state::State> DatastreamBuilder<'a, S> {
    /// Set the `resultScaleFactor` field (optional)
    pub fn result_scale_factor(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `resultScaleFactor` field to an Option value (optional)
    pub fn maybe_result_scale_factor(mut self, value: Option<i64>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::Sensor: datastream_state::IsUnset,
{
    /// Set the `sensor` field (required)
    pub fn sensor(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> DatastreamBuilder<'a, datastream_state::SetSensor<S>> {
        self._fields.7 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::Thing: datastream_state::IsUnset,
{
    /// Set the `thing` field (required)
    pub fn thing(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> DatastreamBuilder<'a, datastream_state::SetThing<S>> {
        self._fields.8 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::UnitOfMeasurement: datastream_state::IsUnset,
{
    /// Set the `unitOfMeasurement` field (required)
    pub fn unit_of_measurement(
        mut self,
        value: impl Into<datastream::UnitOfMeasurement<'a>>,
    ) -> DatastreamBuilder<'a, datastream_state::SetUnitOfMeasurement<S>> {
        self._fields.9 = Option::Some(value.into());
        DatastreamBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: datastream_state::State> DatastreamBuilder<'a, S> {
    /// Set the `verticalDatum` field (optional)
    pub fn vertical_datum(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `verticalDatum` field to an Option value (optional)
    pub fn maybe_vertical_datum(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S> DatastreamBuilder<'a, S>
where
    S: datastream_state::State,
    S::ObservationType: datastream_state::IsSet,
    S::ObservedProperty: datastream_state::IsSet,
    S::CreatedAt: datastream_state::IsSet,
    S::Sensor: datastream_state::IsSet,
    S::UnitOfMeasurement: datastream_state::IsSet,
    S::Name: datastream_state::IsSet,
    S::Thing: datastream_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Datastream<'a> {
        Datastream {
            created_at: self._fields.0.unwrap(),
            description: self._fields.1,
            name: self._fields.2.unwrap(),
            observation_type: self._fields.3.unwrap(),
            observed_area: self._fields.4,
            observed_property: self._fields.5.unwrap(),
            result_scale_factor: self._fields.6,
            sensor: self._fields.7.unwrap(),
            thing: self._fields.8.unwrap(),
            unit_of_measurement: self._fields.9.unwrap(),
            vertical_datum: self._fields.10,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> Datastream<'a> {
        Datastream {
            created_at: self._fields.0.unwrap(),
            description: self._fields.1,
            name: self._fields.2.unwrap(),
            observation_type: self._fields.3.unwrap(),
            observed_area: self._fields.4,
            observed_property: self._fields.5.unwrap(),
            result_scale_factor: self._fields.6,
            sensor: self._fields.7.unwrap(),
            thing: self._fields.8.unwrap(),
            unit_of_measurement: self._fields.9.unwrap(),
            vertical_datum: self._fields.10,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_dev_sensorthings_datastream() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("dev.sensorthings.datastream"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Groups Observations of one ObservedProperty by one Sensor on one Thing. Carries all context needed to interpret observation results.",
                        ),
                    ),
                    key: Some(CowStr::new_static("any")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"), SmolStr::new_static("thing"),
                                SmolStr::new_static("sensor"),
                                SmolStr::new_static("observedProperty"),
                                SmolStr::new_static("unitOfMeasurement"),
                                SmolStr::new_static("observationType"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("observationType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "O&M observation type URI, e.g. http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("observedArea"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "dev.sensorthings.thing#geoPoint",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("observedProperty"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI of the dev.sensorthings.observedProperty record",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("resultScaleFactor"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sensor"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI of the dev.sensorthings.sensor record",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("thing"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI of the dev.sensorthings.thing record",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("unitOfMeasurement"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#unitOfMeasurement"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("verticalDatum"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Vertical datum reference for water level or elevation measurements. Either a URI (e.g. http://www.opengis.net/def/crs/EPSG/0/5731 for Malin Head) or a human-readable identifier (e.g. 'Chart Datum', 'local-gauge-zero'). Absent for non-vertical measurements.",
                                        ),
                                    ),
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("unitOfMeasurement"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("UCUM-compatible unit description."),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("name"), SmolStr::new_static("symbol")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("definition"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URI from QUDT, UCUM, or similar unit ontology",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("symbol"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}