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
from uuid import UUID

@dataclass
class WithChangeOrderGetResponse_results_properties(Parsable):
    # A flag to indicate whether this is a pre-defined attribute or not. Inherited from the custom attribute definition.
    built_in: Optional[bool] = None
    # Name of the custom attribute. Inherited from the custom attribute definition.
    name: Optional[str] = None
    # The order of the custom attribute displayed in the BIM 360 Cost Management. Inherited from the custom attribute definition.
    position: Optional[float] = None
    # The ID of the custom attribute definition. This is the ID from ``/properties``.
    property_definition_id: Optional[UUID] = None
    # The type of the custom attribute. Inherited from the custom attribute definition.
    type: Optional[str] = None
    # The value of the custom attribute.
    value: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithChangeOrderGetResponse_results_properties:
        """
        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: WithChangeOrderGetResponse_results_properties
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithChangeOrderGetResponse_results_properties()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "builtIn": lambda n : setattr(self, 'built_in', n.get_bool_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "position": lambda n : setattr(self, 'position', n.get_float_value()),
            "propertyDefinitionId": lambda n : setattr(self, 'property_definition_id', n.get_uuid_value()),
            "type": lambda n : setattr(self, 'type', n.get_str_value()),
            "value": lambda n : setattr(self, 'value', n.get_str_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_bool_value("builtIn", self.built_in)
        writer.write_str_value("name", self.name)
        writer.write_float_value("position", self.position)
        writer.write_uuid_value("propertyDefinitionId", self.property_definition_id)
        writer.write_str_value("type", self.type)
        writer.write_str_value("value", self.value)
    

