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 .classification_systems_post_request_body_classifications_measurement_type import ClassificationSystemsPostRequestBody_classifications_measurementType

@dataclass
class ClassificationSystemsPostRequestBody_classifications(Parsable):
    # The classification code.Max length: 256
    code: Optional[str] = None
    # A description of the classification.Max length: 256
    description: Optional[str] = None
    # **Deprecated. Will be removed on September 15, 2025.**The type of measurement.Possible values: ``AREA``, ``COUNT``, ``DISTANCE``, ``VOLUME``.
    measurement_type: Optional[ClassificationSystemsPostRequestBody_classifications_measurementType] = None
    # The classification parent code.Its value may be ``null``, indicating that this classification is at the top level of the hierarchy.Max length: 256
    parent_code: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> ClassificationSystemsPostRequestBody_classifications:
        """
        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: ClassificationSystemsPostRequestBody_classifications
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return ClassificationSystemsPostRequestBody_classifications()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .classification_systems_post_request_body_classifications_measurement_type import ClassificationSystemsPostRequestBody_classifications_measurementType

        from .classification_systems_post_request_body_classifications_measurement_type import ClassificationSystemsPostRequestBody_classifications_measurementType

        fields: dict[str, Callable[[Any], None]] = {
            "code": lambda n : setattr(self, 'code', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "measurementType": lambda n : setattr(self, 'measurement_type', n.get_enum_value(ClassificationSystemsPostRequestBody_classifications_measurementType)),
            "parentCode": lambda n : setattr(self, 'parent_code', 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_str_value("code", self.code)
        writer.write_str_value("description", self.description)
        writer.write_enum_value("measurementType", self.measurement_type)
        writer.write_str_value("parentCode", self.parent_code)
    

