//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsenergyformatterunit?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSEnergyFormatterUnit(pub NSInteger);
impl NSEnergyFormatterUnit {
    #[doc(alias = "NSEnergyFormatterUnitJoule")]
    pub const Joule: Self = Self(11);
    #[doc(alias = "NSEnergyFormatterUnitKilojoule")]
    pub const Kilojoule: Self = Self(14);
    #[doc(alias = "NSEnergyFormatterUnitCalorie")]
    pub const Calorie: Self = Self((7 << 8) + 1);
    #[doc(alias = "NSEnergyFormatterUnitKilocalorie")]
    pub const Kilocalorie: Self = Self((7 << 8) + 2);
}

unsafe impl Encode for NSEnergyFormatterUnit {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSEnergyFormatterUnit {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsenergyformatter?language=objc)
    #[unsafe(super(NSFormatter, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSFormatter")]
    pub struct NSEnergyFormatter;
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSCoding for NSEnergyFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSCopying for NSEnergyFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl CopyingHelper for NSEnergyFormatter {
    type Result = Self;
}

#[cfg(feature = "NSFormatter")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSEnergyFormatter {}
);

#[cfg(feature = "NSFormatter")]
impl NSEnergyFormatter {
    extern_methods!(
        #[cfg(feature = "NSNumberFormatter")]
        #[unsafe(method(numberFormatter))]
        #[unsafe(method_family = none)]
        pub fn numberFormatter(&self) -> Retained<NSNumberFormatter>;

        #[cfg(feature = "NSNumberFormatter")]
        /// Setter for [`numberFormatter`][Self::numberFormatter].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setNumberFormatter:))]
        #[unsafe(method_family = none)]
        pub fn setNumberFormatter(&self, number_formatter: Option<&NSNumberFormatter>);

        #[unsafe(method(unitStyle))]
        #[unsafe(method_family = none)]
        pub fn unitStyle(&self) -> NSFormattingUnitStyle;

        /// Setter for [`unitStyle`][Self::unitStyle].
        #[unsafe(method(setUnitStyle:))]
        #[unsafe(method_family = none)]
        pub fn setUnitStyle(&self, unit_style: NSFormattingUnitStyle);

        #[unsafe(method(isForFoodEnergyUse))]
        #[unsafe(method_family = none)]
        pub fn isForFoodEnergyUse(&self) -> bool;

        /// Setter for [`isForFoodEnergyUse`][Self::isForFoodEnergyUse].
        #[unsafe(method(setForFoodEnergyUse:))]
        #[unsafe(method_family = none)]
        pub fn setForFoodEnergyUse(&self, for_food_energy_use: bool);

        #[cfg(feature = "NSString")]
        #[unsafe(method(stringFromValue:unit:))]
        #[unsafe(method_family = none)]
        pub fn stringFromValue_unit(
            &self,
            value: c_double,
            unit: NSEnergyFormatterUnit,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(stringFromJoules:))]
        #[unsafe(method_family = none)]
        pub fn stringFromJoules(&self, number_in_joules: c_double) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(unitStringFromValue:unit:))]
        #[unsafe(method_family = none)]
        pub fn unitStringFromValue_unit(
            &self,
            value: c_double,
            unit: NSEnergyFormatterUnit,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `unitp` must be a valid pointer or null.
        #[unsafe(method(unitStringFromJoules:usedUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitStringFromJoules_usedUnit(
            &self,
            number_in_joules: c_double,
            unitp: *mut NSEnergyFormatterUnit,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `obj` should be of the correct type.
        #[unsafe(method(getObjectValue:forString:errorDescription:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getObjectValue_forString_errorDescription(
            &self,
            obj: Option<&mut Option<Retained<AnyObject>>>,
            string: &NSString,
            error: Option<&mut Option<Retained<NSString>>>,
        ) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSFormatter")]
impl NSEnergyFormatter {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

#[cfg(feature = "NSFormatter")]
impl DefaultRetained for NSEnergyFormatter {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
