// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.gainforest.dwc.measurement
//
// 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, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
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};
/// A measurement, fact, characteristic, or assertion about an occurrence. Multiple measurement records can reference the same occurrence, solving the Simple DwC one-measurement-per-record limitation.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "app.gainforest.dwc.measurement",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Measurement<S: BosStr = DefaultStr> {
    ///Timestamp of record creation in the ATProto PDS.
    pub created_at: Datetime,
    ///The description of the potential error associated with the measurementValue (e.g., '0.5 cm', '5%').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_accuracy: Option<S>,
    ///Person(s) who determined the measurement. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_determined_by: Option<S>,
    ///The date the measurement was made. ISO 8601 format.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_determined_date: Option<S>,
    ///An identifier for the measurement. Should be unique within the dataset.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_id: Option<S>,
    ///The description of or reference to the method used to determine the measurement (e.g., 'diameter tape at 1.3m height', 'laser rangefinder', 'Bitterlich method').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_method: Option<S>,
    ///Comments or notes accompanying the measurement.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_remarks: Option<S>,
    ///The nature of the measurement, fact, characteristic, or assertion (e.g., 'DBH', 'tree height', 'canopy cover', 'tail length', 'body mass', 'soil pH', 'water temperature').
    pub measurement_type: S,
    ///The units for the measurementValue (e.g., 'cm', 'm', 'kg', 'mm', '%', 'degrees Celsius').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_unit: Option<S>,
    ///The value of the measurement, fact, characteristic, or assertion (e.g., '45.2', 'present', 'blue').
    pub measurement_value: S,
    ///The occurrenceID of the linked occurrence record (for cross-system interoperability).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub occurrence_id: Option<S>,
    ///AT-URI reference to the app.gainforest.dwc.occurrence record this measurement belongs to.
    pub occurrence_ref: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// 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 MeasurementGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Measurement<S>,
}

impl<S: BosStr> Measurement<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, MeasurementRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct MeasurementRecord;
impl XrpcResp for MeasurementRecord {
    const NSID: &'static str = "app.gainforest.dwc.measurement";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = MeasurementGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<MeasurementGetRecordOutput<S>> for Measurement<S> {
    fn from(output: MeasurementGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Measurement<S> {
    const NSID: &'static str = "app.gainforest.dwc.measurement";
    type Record = MeasurementRecord;
}

impl Collection for MeasurementRecord {
    const NSID: &'static str = "app.gainforest.dwc.measurement";
    type Record = MeasurementRecord;
}

impl<S: BosStr> LexiconSchema for Measurement<S> {
    fn nsid() -> &'static str {
        "app.gainforest.dwc.measurement"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_dwc_measurement()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.measurement_accuracy {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_accuracy"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_determined_by {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_determined_by"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_determined_date {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_determined_date"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_method {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_method"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 5000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_remarks"),
                        max: 5000usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.measurement_type;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_type"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_unit {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_unit"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.measurement_value;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_value"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.occurrence_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("occurrence_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod measurement_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 CreatedAt;
        type MeasurementType;
        type MeasurementValue;
        type OccurrenceRef;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type MeasurementType = Unset;
        type MeasurementValue = Unset;
        type OccurrenceRef = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type MeasurementType = St::MeasurementType;
        type MeasurementValue = St::MeasurementValue;
        type OccurrenceRef = St::OccurrenceRef;
    }
    ///State transition - sets the `measurement_type` field to Set
    pub struct SetMeasurementType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMeasurementType<St> {}
    impl<St: State> State for SetMeasurementType<St> {
        type CreatedAt = St::CreatedAt;
        type MeasurementType = Set<members::measurement_type>;
        type MeasurementValue = St::MeasurementValue;
        type OccurrenceRef = St::OccurrenceRef;
    }
    ///State transition - sets the `measurement_value` field to Set
    pub struct SetMeasurementValue<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMeasurementValue<St> {}
    impl<St: State> State for SetMeasurementValue<St> {
        type CreatedAt = St::CreatedAt;
        type MeasurementType = St::MeasurementType;
        type MeasurementValue = Set<members::measurement_value>;
        type OccurrenceRef = St::OccurrenceRef;
    }
    ///State transition - sets the `occurrence_ref` field to Set
    pub struct SetOccurrenceRef<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOccurrenceRef<St> {}
    impl<St: State> State for SetOccurrenceRef<St> {
        type CreatedAt = St::CreatedAt;
        type MeasurementType = St::MeasurementType;
        type MeasurementValue = St::MeasurementValue;
        type OccurrenceRef = Set<members::occurrence_ref>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `measurement_type` field
        pub struct measurement_type(());
        ///Marker type for the `measurement_value` field
        pub struct measurement_value(());
        ///Marker type for the `occurrence_ref` field
        pub struct occurrence_ref(());
    }
}

/// Builder for constructing an instance of this type.
pub struct MeasurementBuilder<St: measurement_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<AtUri<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Measurement<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> MeasurementBuilder<measurement_state::Empty, DefaultStr> {
        MeasurementBuilder::new()
    }
}

impl<S: BosStr> Measurement<S> {
    /// Create a new builder for this type
    pub fn builder() -> MeasurementBuilder<measurement_state::Empty, S> {
        MeasurementBuilder::builder()
    }
}

impl MeasurementBuilder<measurement_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        MeasurementBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> MeasurementBuilder<measurement_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        MeasurementBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

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

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementAccuracy` field (optional)
    pub fn measurement_accuracy(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `measurementAccuracy` field to an Option value (optional)
    pub fn maybe_measurement_accuracy(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementDeterminedBy` field (optional)
    pub fn measurement_determined_by(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `measurementDeterminedBy` field to an Option value (optional)
    pub fn maybe_measurement_determined_by(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementDeterminedDate` field (optional)
    pub fn measurement_determined_date(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `measurementDeterminedDate` field to an Option value (optional)
    pub fn maybe_measurement_determined_date(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementID` field (optional)
    pub fn measurement_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `measurementID` field to an Option value (optional)
    pub fn maybe_measurement_id(mut self, value: Option<S>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementMethod` field (optional)
    pub fn measurement_method(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `measurementMethod` field to an Option value (optional)
    pub fn maybe_measurement_method(mut self, value: Option<S>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementRemarks` field (optional)
    pub fn measurement_remarks(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `measurementRemarks` field to an Option value (optional)
    pub fn maybe_measurement_remarks(mut self, value: Option<S>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::MeasurementType: measurement_state::IsUnset,
{
    /// Set the `measurementType` field (required)
    pub fn measurement_type(
        mut self,
        value: impl Into<S>,
    ) -> MeasurementBuilder<measurement_state::SetMeasurementType<St>, S> {
        self._fields.7 = Option::Some(value.into());
        MeasurementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurementUnit` field (optional)
    pub fn measurement_unit(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `measurementUnit` field to an Option value (optional)
    pub fn maybe_measurement_unit(mut self, value: Option<S>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::MeasurementValue: measurement_state::IsUnset,
{
    /// Set the `measurementValue` field (required)
    pub fn measurement_value(
        mut self,
        value: impl Into<S>,
    ) -> MeasurementBuilder<measurement_state::SetMeasurementValue<St>, S> {
        self._fields.9 = Option::Some(value.into());
        MeasurementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `occurrenceID` field (optional)
    pub fn occurrence_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `occurrenceID` field to an Option value (optional)
    pub fn maybe_occurrence_id(mut self, value: Option<S>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::OccurrenceRef: measurement_state::IsUnset,
{
    /// Set the `occurrenceRef` field (required)
    pub fn occurrence_ref(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> MeasurementBuilder<measurement_state::SetOccurrenceRef<St>, S> {
        self._fields.11 = Option::Some(value.into());
        MeasurementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::CreatedAt: measurement_state::IsSet,
    St::MeasurementType: measurement_state::IsSet,
    St::MeasurementValue: measurement_state::IsSet,
    St::OccurrenceRef: measurement_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Measurement<S> {
        Measurement {
            created_at: self._fields.0.unwrap(),
            measurement_accuracy: self._fields.1,
            measurement_determined_by: self._fields.2,
            measurement_determined_date: self._fields.3,
            measurement_id: self._fields.4,
            measurement_method: self._fields.5,
            measurement_remarks: self._fields.6,
            measurement_type: self._fields.7.unwrap(),
            measurement_unit: self._fields.8,
            measurement_value: self._fields.9.unwrap(),
            occurrence_id: self._fields.10,
            occurrence_ref: self._fields.11.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> Measurement<S> {
        Measurement {
            created_at: self._fields.0.unwrap(),
            measurement_accuracy: self._fields.1,
            measurement_determined_by: self._fields.2,
            measurement_determined_date: self._fields.3,
            measurement_id: self._fields.4,
            measurement_method: self._fields.5,
            measurement_remarks: self._fields.6,
            measurement_type: self._fields.7.unwrap(),
            measurement_unit: self._fields.8,
            measurement_value: self._fields.9.unwrap(),
            occurrence_id: self._fields.10,
            occurrence_ref: self._fields.11.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_gainforest_dwc_measurement() -> 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("app.gainforest.dwc.measurement"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A measurement, fact, characteristic, or assertion about an occurrence. Multiple measurement records can reference the same occurrence, solving the Simple DwC one-measurement-per-record limitation.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("occurrenceRef"),
                                SmolStr::new_static("measurementType"),
                                SmolStr::new_static("measurementValue"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Timestamp of record creation in the ATProto PDS.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementAccuracy"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The description of the potential error associated with the measurementValue (e.g., '0.5 cm', '5%').",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementDeterminedBy"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Person(s) who determined the measurement. Pipe-delimited for multiple.",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementDeterminedDate"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The date the measurement was made. ISO 8601 format.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "An identifier for the measurement. Should be unique within the dataset.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementMethod"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The description of or reference to the method used to determine the measurement (e.g., 'diameter tape at 1.3m height', 'laser rangefinder', 'Bitterlich method').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementRemarks"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Comments or notes accompanying the measurement.",
                                        ),
                                    ),
                                    max_graphemes: Some(5000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The nature of the measurement, fact, characteristic, or assertion (e.g., 'DBH', 'tree height', 'canopy cover', 'tail length', 'body mass', 'soil pH', 'water temperature').",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementUnit"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The units for the measurementValue (e.g., 'cm', 'm', 'kg', 'mm', '%', 'degrees Celsius').",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurementValue"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The value of the measurement, fact, characteristic, or assertion (e.g., '45.2', 'present', 'blue').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("occurrenceID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The occurrenceID of the linked occurrence record (for cross-system interoperability).",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("occurrenceRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI reference to the app.gainforest.dwc.occurrence record this measurement belongs to.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}