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

@dataclass
class WithSegmentPatchRequestBody(Parsable):
    # The delimiter that follows the segment. Possible values are: ``none``, ``space``, ``point``, ``hyphen``, ``underscore``, ``tab``.
    delimiter: Optional[str] = None
    # ``true`` Lock the segment.``false`` Do not lock the segment.
    is_locked: Optional[bool] = None
    # The number of characters allowed in the segment.
    length: Optional[float] = None
    # The name of the segment in budget code template.Max length: 1024
    name: Optional[str] = None
    # A code sample for the segment used to demonstrate how the segment looks when displayed.
    sample_code: Optional[str] = None
    # The segment type. Possible values: ``code``, ``column``, or ``info``. Code segments are displayed as part of the budget code. Column segments are displayed in a separate column. Info segments are not displayed.
    type: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithSegmentPatchRequestBody:
        """
        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: WithSegmentPatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithSegmentPatchRequestBody()
    
    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]] = {
            "delimiter": lambda n : setattr(self, 'delimiter', n.get_str_value()),
            "isLocked": lambda n : setattr(self, 'is_locked', n.get_bool_value()),
            "length": lambda n : setattr(self, 'length', n.get_float_value()),
            "name": lambda n : setattr(self, 'name', n.get_str_value()),
            "sampleCode": lambda n : setattr(self, 'sample_code', n.get_str_value()),
            "type": lambda n : setattr(self, 'type', 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("delimiter", self.delimiter)
        writer.write_bool_value("isLocked", self.is_locked)
        writer.write_float_value("length", self.length)
        writer.write_str_value("name", self.name)
        writer.write_str_value("sampleCode", self.sample_code)
        writer.write_str_value("type", self.type)
    

