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 .requirements_get_response_spec_sections_submittal_groups import RequirementsGetResponse_specSections_submittalGroups

@dataclass
class RequirementsGetResponse_specSections(Parsable):
    # The CSI specification code of the submittal. This is equivalent to the *Section number* column in the UI.
    spec_code: Optional[str] = None
    # The CSI specification name of the submittal. This is equivalent of the *Section name* column in the UI.
    spec_name: Optional[str] = None
    # A list of submittal groups.
    submittal_groups: Optional[list[RequirementsGetResponse_specSections_submittalGroups]] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> RequirementsGetResponse_specSections:
        """
        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: RequirementsGetResponse_specSections
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return RequirementsGetResponse_specSections()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .requirements_get_response_spec_sections_submittal_groups import RequirementsGetResponse_specSections_submittalGroups

        from .requirements_get_response_spec_sections_submittal_groups import RequirementsGetResponse_specSections_submittalGroups

        fields: dict[str, Callable[[Any], None]] = {
            "specCode": lambda n : setattr(self, 'spec_code', n.get_str_value()),
            "specName": lambda n : setattr(self, 'spec_name', n.get_str_value()),
            "submittalGroups": lambda n : setattr(self, 'submittal_groups', n.get_collection_of_object_values(RequirementsGetResponse_specSections_submittalGroups)),
        }
        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("specCode", self.spec_code)
        writer.write_str_value("specName", self.spec_name)
        writer.write_collection_of_object_values("submittalGroups", self.submittal_groups)
    

