"""LoadedNeedleRollerBearingElement"""
from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar

from mastapy._private._internal.dataclasses import extended_dataclass
from mastapy._private._internal.type_enforcement import enforce_parameter_types
from mastapy._private._internal import utility
from mastapy._private.bearings.bearing_results.rolling import _2061
from mastapy._private._internal.cast_exception import CastException
from mastapy._private._internal.python_net import python_net_import

_LOADED_NEEDLE_ROLLER_BEARING_ELEMENT = python_net_import(
    "SMT.MastaAPI.Bearings.BearingResults.Rolling", "LoadedNeedleRollerBearingElement"
)

if TYPE_CHECKING:
    from typing import Any, Type, TypeVar

    from mastapy._private.bearings.bearing_results.rolling import _2080, _2081, _2067

    Self = TypeVar("Self", bound="LoadedNeedleRollerBearingElement")
    CastSelf = TypeVar(
        "CastSelf",
        bound="LoadedNeedleRollerBearingElement._Cast_LoadedNeedleRollerBearingElement",
    )


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


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

    __parent__: "LoadedNeedleRollerBearingElement"

    @property
    def loaded_cylindrical_roller_bearing_element(
        self: "CastSelf",
    ) -> "_2061.LoadedCylindricalRollerBearingElement":
        return self.__parent__._cast(_2061.LoadedCylindricalRollerBearingElement)

    @property
    def loaded_non_barrel_roller_element(
        self: "CastSelf",
    ) -> "_2080.LoadedNonBarrelRollerElement":
        from mastapy._private.bearings.bearing_results.rolling import _2080

        return self.__parent__._cast(_2080.LoadedNonBarrelRollerElement)

    @property
    def loaded_roller_bearing_element(
        self: "CastSelf",
    ) -> "_2081.LoadedRollerBearingElement":
        from mastapy._private.bearings.bearing_results.rolling import _2081

        return self.__parent__._cast(_2081.LoadedRollerBearingElement)

    @property
    def loaded_element(self: "CastSelf") -> "_2067.LoadedElement":
        from mastapy._private.bearings.bearing_results.rolling import _2067

        return self.__parent__._cast(_2067.LoadedElement)

    @property
    def loaded_needle_roller_bearing_element(
        self: "CastSelf",
    ) -> "LoadedNeedleRollerBearingElement":
        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)
class LoadedNeedleRollerBearingElement(_2061.LoadedCylindricalRollerBearingElement):
    """LoadedNeedleRollerBearingElement

    This is a mastapy class.
    """

    TYPE: ClassVar["Type"] = _LOADED_NEEDLE_ROLLER_BEARING_ELEMENT

    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 sliding_power_loss_from_hysteresis(self: "Self") -> "float":
        """float"""
        temp = self.wrapped.SlidingPowerLossFromHysteresis

        if temp is None:
            return 0.0

        return temp

    @sliding_power_loss_from_hysteresis.setter
    @enforce_parameter_types
    def sliding_power_loss_from_hysteresis(self: "Self", value: "float") -> None:
        self.wrapped.SlidingPowerLossFromHysteresis = (
            float(value) if value is not None else 0.0
        )

    @property
    def sliding_power_loss_from_macro_sliding_due_to_roller_skew(
        self: "Self",
    ) -> "float":
        """float"""
        temp = self.wrapped.SlidingPowerLossFromMacroSlidingDueToRollerSkew

        if temp is None:
            return 0.0

        return temp

    @sliding_power_loss_from_macro_sliding_due_to_roller_skew.setter
    @enforce_parameter_types
    def sliding_power_loss_from_macro_sliding_due_to_roller_skew(
        self: "Self", value: "float"
    ) -> None:
        self.wrapped.SlidingPowerLossFromMacroSlidingDueToRollerSkew = (
            float(value) if value is not None else 0.0
        )

    @property
    def sliding_power_loss_roller_cage_axial_component(self: "Self") -> "float":
        """float"""
        temp = self.wrapped.SlidingPowerLossRollerCageAxialComponent

        if temp is None:
            return 0.0

        return temp

    @sliding_power_loss_roller_cage_axial_component.setter
    @enforce_parameter_types
    def sliding_power_loss_roller_cage_axial_component(
        self: "Self", value: "float"
    ) -> None:
        self.wrapped.SlidingPowerLossRollerCageAxialComponent = (
            float(value) if value is not None else 0.0
        )

    @property
    def sliding_power_loss_roller_cage_moment_component(self: "Self") -> "float":
        """float"""
        temp = self.wrapped.SlidingPowerLossRollerCageMomentComponent

        if temp is None:
            return 0.0

        return temp

    @sliding_power_loss_roller_cage_moment_component.setter
    @enforce_parameter_types
    def sliding_power_loss_roller_cage_moment_component(
        self: "Self", value: "float"
    ) -> None:
        self.wrapped.SlidingPowerLossRollerCageMomentComponent = (
            float(value) if value is not None else 0.0
        )

    @property
    def sliding_power_loss_roller_cage_radial_component(self: "Self") -> "float":
        """float"""
        temp = self.wrapped.SlidingPowerLossRollerCageRadialComponent

        if temp is None:
            return 0.0

        return temp

    @sliding_power_loss_roller_cage_radial_component.setter
    @enforce_parameter_types
    def sliding_power_loss_roller_cage_radial_component(
        self: "Self", value: "float"
    ) -> None:
        self.wrapped.SlidingPowerLossRollerCageRadialComponent = (
            float(value) if value is not None else 0.0
        )

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

        Returns:
            _Cast_LoadedNeedleRollerBearingElement
        """
        return _Cast_LoadedNeedleRollerBearingElement(self)
