from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
    from .with_takeoff_item_get_response_property_values_source import WithTakeoffItemGetResponse_propertyValues_source
    from .with_takeoff_item_get_response_property_values_unit_of_measure import WithTakeoffItemGetResponse_propertyValues_unitOfMeasure
    from .with_takeoff_item_get_response_property_values_value import WithTakeoffItemGetResponse_propertyValues_value

@dataclass
class WithTakeoffItemGetResponse_propertyValues(Parsable):
    # Name of the property.
    name: Optional[str] = None
    # Specifies how a takeoff property value was obtained.Possible values: ``MANUAL_ENTRY``, ``BIM_PROPERTY``, ``MEASUREMENT``
    source: Optional[WithTakeoffItemGetResponse_propertyValues_source] = None
    # The unit of measurement.Possible values: ``EA``, ``IN``, ``LF``, ``YD``, ``SI``, ``SF``, ``SY``, ``CI``, ``CF``, ``CY``, ``LBS``, ``TON``, ``MM``, ``M``, ``M2``, ``M3``, ``KG``, ``T``.
    unit_of_measure: Optional[WithTakeoffItemGetResponse_propertyValues_unitOfMeasure] = None
    # The value of a takeoff instance.
    value: Optional[WithTakeoffItemGetResponse_propertyValues_value] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithTakeoffItemGetResponse_propertyValues:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: WithTakeoffItemGetResponse_propertyValues
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithTakeoffItemGetResponse_propertyValues()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .with_takeoff_item_get_response_property_values_source import WithTakeoffItemGetResponse_propertyValues_source
        from .with_takeoff_item_get_response_property_values_unit_of_measure import WithTakeoffItemGetResponse_propertyValues_unitOfMeasure
        from .with_takeoff_item_get_response_property_values_value import WithTakeoffItemGetResponse_propertyValues_value

        from .with_takeoff_item_get_response_property_values_source import WithTakeoffItemGetResponse_propertyValues_source
        from .with_takeoff_item_get_response_property_values_unit_of_measure import WithTakeoffItemGetResponse_propertyValues_unitOfMeasure
        from .with_takeoff_item_get_response_property_values_value import WithTakeoffItemGetResponse_propertyValues_value

        fields: dict[str, Callable[[Any], None]] = {
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "source": lambda n : setattr(self, 'source', n.get_enum_value(WithTakeoffItemGetResponse_propertyValues_source)),
            "unitOfMeasure": lambda n : setattr(self, 'unit_of_measure', n.get_enum_value(WithTakeoffItemGetResponse_propertyValues_unitOfMeasure)),
            "value": lambda n : setattr(self, 'value', n.get_object_value(WithTakeoffItemGetResponse_propertyValues_value)),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_str_value("name", self.name)
        writer.write_enum_value("source", self.source)
        writer.write_enum_value("unitOfMeasure", self.unit_of_measure)
        writer.write_object_value("value", self.value)
    

