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_type_get_response_property_definitions_unit_of_measure import WithTakeoffTypeGetResponse_propertyDefinitions_unitOfMeasure
    from .with_takeoff_type_get_response_property_definitions_value_location import WithTakeoffTypeGetResponse_propertyDefinitions_valueLocation

@dataclass
class WithTakeoffTypeGetResponse_propertyDefinitions(Parsable):
    # The name of the property.Max length: 256
    name: Optional[str] = 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[WithTakeoffTypeGetResponse_propertyDefinitions_unitOfMeasure] = None
    # The value of the property.
    value: Optional[float] = None
    # The location of the value.For properties Length, Width, Height, Depth and Thickness: ``valueLocation`` is ``INSTANCE_WITH_TAKEOFF_TYPE_DEFAULT``.For properties WeightByLength, WeightByArea and WeightByVolume: ``valueLocation`` is ``TAKEOFF_TYPE``.Possible values: ``TAKEOFF_TYPE``, ``INSTANCE_WITH_TAKEOFF_TYPE_DEFAULT``
    value_location: Optional[WithTakeoffTypeGetResponse_propertyDefinitions_valueLocation] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithTakeoffTypeGetResponse_propertyDefinitions:
        """
        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: WithTakeoffTypeGetResponse_propertyDefinitions
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithTakeoffTypeGetResponse_propertyDefinitions()
    
    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_type_get_response_property_definitions_unit_of_measure import WithTakeoffTypeGetResponse_propertyDefinitions_unitOfMeasure
        from .with_takeoff_type_get_response_property_definitions_value_location import WithTakeoffTypeGetResponse_propertyDefinitions_valueLocation

        from .with_takeoff_type_get_response_property_definitions_unit_of_measure import WithTakeoffTypeGetResponse_propertyDefinitions_unitOfMeasure
        from .with_takeoff_type_get_response_property_definitions_value_location import WithTakeoffTypeGetResponse_propertyDefinitions_valueLocation

        fields: dict[str, Callable[[Any], None]] = {
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "unitOfMeasure": lambda n : setattr(self, 'unit_of_measure', n.get_enum_value(WithTakeoffTypeGetResponse_propertyDefinitions_unitOfMeasure)),
            "value": lambda n : setattr(self, 'value', n.get_float_value()),
            "valueLocation": lambda n : setattr(self, 'value_location', n.get_enum_value(WithTakeoffTypeGetResponse_propertyDefinitions_valueLocation)),
        }
        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("unitOfMeasure", self.unit_of_measure)
        writer.write_float_value("value", self.value)
        writer.write_enum_value("valueLocation", self.value_location)
    

