# coding: utf-8

"""
    ICAT+ API

    ICAT+ RESTful API with Swagger

    The version of the OpenAPI document: 1.0.0
    Contact: demariaa@esrf.fr
    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 pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List, Optional
from icat_plus_client.models.mxshell import Mxshell
from typing import Optional, Set
from typing_extensions import Self

class Mxcutoffs(BaseModel):
    """
    mx filter cutoffs
    """ # noqa: E501
    completeness: Optional[Mxshell] = None
    resolution_limit_low: Optional[Mxshell] = None
    resolution_limit_high: Optional[Mxshell] = None
    r_meas_all_i_plus_i_minus: Optional[Mxshell] = Field(default=None, alias="r_meas_all_IPlus_IMinus")
    mean_i_over_sig_i: Optional[Mxshell] = Field(default=None, alias="mean_I_over_sigI")
    cc_half: Optional[Mxshell] = None
    cc_ano: Optional[Mxshell] = None
    __properties: ClassVar[List[str]] = ["completeness", "resolution_limit_low", "resolution_limit_high", "r_meas_all_IPlus_IMinus", "mean_I_over_sigI", "cc_half", "cc_ano"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    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) -> Optional[Self]:
        """Create an instance of Mxcutoffs 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.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of completeness
        if self.completeness:
            _dict['completeness'] = self.completeness.to_dict()
        # override the default output from pydantic by calling `to_dict()` of resolution_limit_low
        if self.resolution_limit_low:
            _dict['resolution_limit_low'] = self.resolution_limit_low.to_dict()
        # override the default output from pydantic by calling `to_dict()` of resolution_limit_high
        if self.resolution_limit_high:
            _dict['resolution_limit_high'] = self.resolution_limit_high.to_dict()
        # override the default output from pydantic by calling `to_dict()` of r_meas_all_i_plus_i_minus
        if self.r_meas_all_i_plus_i_minus:
            _dict['r_meas_all_IPlus_IMinus'] = self.r_meas_all_i_plus_i_minus.to_dict()
        # override the default output from pydantic by calling `to_dict()` of mean_i_over_sig_i
        if self.mean_i_over_sig_i:
            _dict['mean_I_over_sigI'] = self.mean_i_over_sig_i.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cc_half
        if self.cc_half:
            _dict['cc_half'] = self.cc_half.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cc_ano
        if self.cc_ano:
            _dict['cc_ano'] = self.cc_ano.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Mxcutoffs from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "completeness": Mxshell.from_dict(obj["completeness"]) if obj.get("completeness") is not None else None,
            "resolution_limit_low": Mxshell.from_dict(obj["resolution_limit_low"]) if obj.get("resolution_limit_low") is not None else None,
            "resolution_limit_high": Mxshell.from_dict(obj["resolution_limit_high"]) if obj.get("resolution_limit_high") is not None else None,
            "r_meas_all_IPlus_IMinus": Mxshell.from_dict(obj["r_meas_all_IPlus_IMinus"]) if obj.get("r_meas_all_IPlus_IMinus") is not None else None,
            "mean_I_over_sigI": Mxshell.from_dict(obj["mean_I_over_sigI"]) if obj.get("mean_I_over_sigI") is not None else None,
            "cc_half": Mxshell.from_dict(obj["cc_half"]) if obj.get("cc_half") is not None else None,
            "cc_ano": Mxshell.from_dict(obj["cc_ano"]) if obj.get("cc_ano") is not None else None
        })
        return _obj


