"""BearingConnectionComponent"""

from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar

from mastapy._private._internal.dataclasses import extended_dataclass
from mastapy._private._internal.exceptions import CastException
from mastapy._private._internal.python_net import python_net_import

from mastapy._private import _0
from mastapy._private._internal import utility

_BEARING_CONNECTION_COMPONENT = python_net_import(
    "SMT.MastaAPI.Bearings.Tolerances", "BearingConnectionComponent"
)

if TYPE_CHECKING:
    from typing import Any, Type, TypeVar

    from mastapy._private.bearings.tolerances import (
        _2145,
        _2146,
        _2147,
        _2148,
        _2150,
        _2151,
        _2152,
        _2155,
        _2156,
        _2159,
        _2161,
    )

    Self = TypeVar("Self", bound="BearingConnectionComponent")
    CastSelf = TypeVar(
        "CastSelf", bound="BearingConnectionComponent._Cast_BearingConnectionComponent"
    )


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


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

    __parent__: "BearingConnectionComponent"

    @property
    def inner_ring_tolerance(self: "CastSelf") -> "_2145.InnerRingTolerance":
        from mastapy._private.bearings.tolerances import _2145

        return self.__parent__._cast(_2145.InnerRingTolerance)

    @property
    def inner_support_tolerance(self: "CastSelf") -> "_2146.InnerSupportTolerance":
        from mastapy._private.bearings.tolerances import _2146

        return self.__parent__._cast(_2146.InnerSupportTolerance)

    @property
    def interference_detail(self: "CastSelf") -> "_2147.InterferenceDetail":
        from mastapy._private.bearings.tolerances import _2147

        return self.__parent__._cast(_2147.InterferenceDetail)

    @property
    def interference_tolerance(self: "CastSelf") -> "_2148.InterferenceTolerance":
        from mastapy._private.bearings.tolerances import _2148

        return self.__parent__._cast(_2148.InterferenceTolerance)

    @property
    def mounting_sleeve_diameter_detail(
        self: "CastSelf",
    ) -> "_2150.MountingSleeveDiameterDetail":
        from mastapy._private.bearings.tolerances import _2150

        return self.__parent__._cast(_2150.MountingSleeveDiameterDetail)

    @property
    def outer_ring_tolerance(self: "CastSelf") -> "_2151.OuterRingTolerance":
        from mastapy._private.bearings.tolerances import _2151

        return self.__parent__._cast(_2151.OuterRingTolerance)

    @property
    def outer_support_tolerance(self: "CastSelf") -> "_2152.OuterSupportTolerance":
        from mastapy._private.bearings.tolerances import _2152

        return self.__parent__._cast(_2152.OuterSupportTolerance)

    @property
    def ring_detail(self: "CastSelf") -> "_2155.RingDetail":
        from mastapy._private.bearings.tolerances import _2155

        return self.__parent__._cast(_2155.RingDetail)

    @property
    def ring_tolerance(self: "CastSelf") -> "_2156.RingTolerance":
        from mastapy._private.bearings.tolerances import _2156

        return self.__parent__._cast(_2156.RingTolerance)

    @property
    def support_detail(self: "CastSelf") -> "_2159.SupportDetail":
        from mastapy._private.bearings.tolerances import _2159

        return self.__parent__._cast(_2159.SupportDetail)

    @property
    def support_tolerance(self: "CastSelf") -> "_2161.SupportTolerance":
        from mastapy._private.bearings.tolerances import _2161

        return self.__parent__._cast(_2161.SupportTolerance)

    @property
    def bearing_connection_component(self: "CastSelf") -> "BearingConnectionComponent":
        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 BearingConnectionComponent(_0.APIBase):
    """BearingConnectionComponent

    This is a mastapy class.
    """

    TYPE: ClassVar["Type"] = _BEARING_CONNECTION_COMPONENT

    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
    def cast_to(self: "Self") -> "_Cast_BearingConnectionComponent":
        """Cast to another type.

        Returns:
            _Cast_BearingConnectionComponent
        """
        return _Cast_BearingConnectionComponent(self)
