// @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;

#[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};
use jacquard_common::types::uri::{RecordUri, UriError};
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.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Measurement<'a> {
    ///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")]
    #[serde(borrow)]
    pub measurement_accuracy: Option<CowStr<'a>>,
    ///Person(s) who determined the measurement. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_determined_by: Option<CowStr<'a>>,
    ///The date the measurement was made. ISO 8601 format.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_determined_date: Option<CowStr<'a>>,
    ///An identifier for the measurement. Should be unique within the dataset.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_id: Option<CowStr<'a>>,
    ///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")]
    #[serde(borrow)]
    pub measurement_method: Option<CowStr<'a>>,
    ///Comments or notes accompanying the measurement.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_remarks: Option<CowStr<'a>>,
    ///The nature of the measurement, fact, characteristic, or assertion (e.g., 'DBH', 'tree height', 'canopy cover', 'tail length', 'body mass', 'soil pH', 'water temperature').
    #[serde(borrow)]
    pub measurement_type: CowStr<'a>,
    ///The units for the measurementValue (e.g., 'cm', 'm', 'kg', 'mm', '%', 'degrees Celsius').
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_unit: Option<CowStr<'a>>,
    ///The value of the measurement, fact, characteristic, or assertion (e.g., '45.2', 'present', 'blue').
    #[serde(borrow)]
    pub measurement_value: CowStr<'a>,
    ///The occurrenceID of the linked occurrence record (for cross-system interoperability).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub occurrence_id: Option<CowStr<'a>>,
    ///AT-URI reference to the app.gainforest.dwc.occurrence record this measurement belongs to.
    #[serde(borrow)]
    pub occurrence_ref: AtUri<'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 MeasurementGetRecordOutput<'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: Measurement<'a>,
}

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

/// 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<'de> = MeasurementGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

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

/// Builder for constructing an instance of this type
pub struct MeasurementBuilder<'a, S: measurement_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<AtUri<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementAccuracy` field (optional)
    pub fn measurement_accuracy(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementDeterminedBy` field (optional)
    pub fn measurement_determined_by(
        mut self,
        value: impl Into<Option<CowStr<'a>>>,
    ) -> 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<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementDeterminedDate` field (optional)
    pub fn measurement_determined_date(
        mut self,
        value: impl Into<Option<CowStr<'a>>>,
    ) -> 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<CowStr<'a>>,
    ) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementID` field (optional)
    pub fn measurement_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementMethod` field (optional)
    pub fn measurement_method(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementRemarks` field (optional)
    pub fn measurement_remarks(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurementUnit` field (optional)
    pub fn measurement_unit(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `occurrenceID` field (optional)
    pub fn occurrence_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.10 = value;
        self
    }
}

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

impl<'a, S> MeasurementBuilder<'a, S>
where
    S: measurement_state::State,
    S::MeasurementValue: measurement_state::IsSet,
    S::CreatedAt: measurement_state::IsSet,
    S::OccurrenceRef: measurement_state::IsSet,
    S::MeasurementType: measurement_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Measurement<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Measurement<'a> {
        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()
    }
}