# coding: utf-8

"""
    RTU MIREA VUC Schedule

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.1
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import Any, Optional
from pydantic import BaseModel
from schedule_service_client.models.shape import Shape
from typing import Dict, Any
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class WorksheetSettings(BaseModel):
    """
    WorksheetSettings
    """
    day_range: Optional[Shape] = None
    year_range: Optional[Shape] = None
    days_in_week_column_number: Optional[Any] = None
    platoon_column_number: Optional[Any] = None
    subject_rows_number: Optional[Any] = None
    __properties: ClassVar[List[str]] = ["day_range", "year_range", "days_in_week_column_number", "platoon_column_number", "subject_rows_number"]

    model_config = {
        "populate_by_name": True,
        "validate_assignment": True
    }


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Self:
        """Create an instance of WorksheetSettings from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of day_range
        if self.day_range:
            _dict['day_range'] = self.day_range.to_dict()
        # override the default output from pydantic by calling `to_dict()` of year_range
        if self.year_range:
            _dict['year_range'] = self.year_range.to_dict()
        # set to None if days_in_week_column_number (nullable) is None
        # and model_fields_set contains the field
        if self.days_in_week_column_number is None and "days_in_week_column_number" in self.model_fields_set:
            _dict['days_in_week_column_number'] = None

        # set to None if platoon_column_number (nullable) is None
        # and model_fields_set contains the field
        if self.platoon_column_number is None and "platoon_column_number" in self.model_fields_set:
            _dict['platoon_column_number'] = None

        # set to None if subject_rows_number (nullable) is None
        # and model_fields_set contains the field
        if self.subject_rows_number is None and "subject_rows_number" in self.model_fields_set:
            _dict['subject_rows_number'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> Self:
        """Create an instance of WorksheetSettings from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "day_range": Shape.from_dict(obj.get("day_range")) if obj.get("day_range") is not None else None,
            "year_range": Shape.from_dict(obj.get("year_range")) if obj.get("year_range") is not None else None,
            "days_in_week_column_number": obj.get("days_in_week_column_number"),
            "platoon_column_number": obj.get("platoon_column_number"),
            "subject_rows_number": obj.get("subject_rows_number")
        })
        return _obj


