"""ThermalConnectorWithResistance"""

from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar

from mastapy._private._internal import utility
from mastapy._private._internal.dataclasses import extended_dataclass
from mastapy._private._internal.exception_bridge import exception_bridge
from mastapy._private._internal.exceptions import CastException
from mastapy._private._internal.python_net import (
    python_net_import,
    pythonnet_property_get,
    pythonnet_property_set,
)
from mastapy._private._internal.type_enforcement import enforce_parameter_types
from mastapy._private.nodal_analysis.lumped_parameter_thermal_analysis import _216

_THERMAL_CONNECTOR_WITH_RESISTANCE = python_net_import(
    "SMT.MastaAPI.NodalAnalysis.LumpedParameterThermalAnalysis",
    "ThermalConnectorWithResistance",
)

if TYPE_CHECKING:
    from typing import Any, Type, TypeVar

    from mastapy._private.nodal_analysis.lumped_parameter_thermal_analysis import (
        _182,
        _229,
    )

    Self = TypeVar("Self", bound="ThermalConnectorWithResistance")
    CastSelf = TypeVar(
        "CastSelf",
        bound="ThermalConnectorWithResistance._Cast_ThermalConnectorWithResistance",
    )


__docformat__ = "restructuredtext en"
__all__ = ("ThermalConnectorWithResistance",)


@extended_dataclass(frozen=True, slots=True, weakref_slot=True)
class _Cast_ThermalConnectorWithResistance:
    """Special nested class for casting ThermalConnectorWithResistance to subclasses."""

    __parent__: "ThermalConnectorWithResistance"

    @property
    def thermal_connector(self: "CastSelf") -> "_216.ThermalConnector":
        return self.__parent__._cast(_216.ThermalConnector)

    @property
    def auto_generated_thermal_connector_with_resistance(
        self: "CastSelf",
    ) -> "_182.AutoGeneratedThermalConnectorWithResistance":
        from mastapy._private.nodal_analysis.lumped_parameter_thermal_analysis import (
            _182,
        )

        return self.__parent__._cast(_182.AutoGeneratedThermalConnectorWithResistance)

    @property
    def user_defined_thermal_connector_with_resistance(
        self: "CastSelf",
    ) -> "_229.UserDefinedThermalConnectorWithResistance":
        from mastapy._private.nodal_analysis.lumped_parameter_thermal_analysis import (
            _229,
        )

        return self.__parent__._cast(_229.UserDefinedThermalConnectorWithResistance)

    @property
    def thermal_connector_with_resistance(
        self: "CastSelf",
    ) -> "ThermalConnectorWithResistance":
        return self.__parent__

    def __getattr__(self: "CastSelf", name: str) -> "Any":
        try:
            return self.__getattribute__(name)
        except AttributeError:
            class_name = utility.camel(name)
            raise CastException(
                f'Detected an invalid cast. Cannot cast to type "{class_name}"'
            ) from None


@extended_dataclass(frozen=True, slots=True, weakref_slot=True, eq=False)
class ThermalConnectorWithResistance(_216.ThermalConnector):
    """ThermalConnectorWithResistance

    This is a mastapy class.
    """

    TYPE: ClassVar["Type"] = _THERMAL_CONNECTOR_WITH_RESISTANCE

    wrapped: "Any"

    def __post_init__(self: "Self") -> None:
        """Override of the post initialisation magic method."""
        if not hasattr(self.wrapped, "reference_count"):
            self.wrapped.reference_count = 0

        self.wrapped.reference_count += 1

    @property
    @exception_bridge
    def thermal_resistance(self: "Self") -> "float":
        """float"""
        temp = pythonnet_property_get(self.wrapped, "ThermalResistance")

        if temp is None:
            return 0.0

        return temp

    @thermal_resistance.setter
    @exception_bridge
    @enforce_parameter_types
    def thermal_resistance(self: "Self", value: "float") -> None:
        pythonnet_property_set(
            self.wrapped,
            "ThermalResistance",
            float(value) if value is not None else 0.0,
        )

    @property
    def cast_to(self: "Self") -> "_Cast_ThermalConnectorWithResistance":
        """Cast to another type.

        Returns:
            _Cast_ThermalConnectorWithResistance
        """
        return _Cast_ThermalConnectorWithResistance(self)
