//! 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::*;

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

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCoding for NSPredicate {}
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCopying for NSPredicate {}
);

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

extern_conformance!(
    unsafe impl NSObjectProtocol for NSPredicate {}
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSSecureCoding for NSPredicate {}
);

impl NSPredicate {
    extern_methods!(
        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        /// # Safety
        ///
        /// `arguments` generic should be of the correct type.
        #[unsafe(method(predicateWithFormat:argumentArray:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateWithFormat_argumentArray(
            predicate_format: &NSString,
            arguments: Option<&NSArray>,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(predicateFromMetadataQueryString:))]
        #[unsafe(method_family = none)]
        pub fn predicateFromMetadataQueryString(
            query_string: &NSString,
        ) -> Option<Retained<NSPredicate>>;

        #[unsafe(method(predicateWithValue:))]
        #[unsafe(method_family = none)]
        pub fn predicateWithValue(value: bool) -> Retained<NSPredicate>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "block2"))]
        #[unsafe(method(predicateWithBlock:))]
        #[unsafe(method_family = none)]
        pub fn predicateWithBlock(
            block: &block2::DynBlock<
                dyn Fn(*mut AnyObject, *mut NSDictionary<NSString, AnyObject>) -> Bool,
            >,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(predicateFormat))]
        #[unsafe(method_family = none)]
        pub fn predicateFormat(&self) -> Retained<NSString>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// # Safety
        ///
        /// `variables` generic should be of the correct type.
        #[unsafe(method(predicateWithSubstitutionVariables:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateWithSubstitutionVariables(
            &self,
            variables: &NSDictionary<NSString, AnyObject>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `object` should be of the correct type.
        #[unsafe(method(evaluateWithObject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn evaluateWithObject(&self, object: Option<&AnyObject>) -> bool;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// # Safety
        ///
        /// - `object` should be of the correct type.
        /// - `bindings` generic should be of the correct type.
        #[unsafe(method(evaluateWithObject:substitutionVariables:))]
        #[unsafe(method_family = none)]
        pub unsafe fn evaluateWithObject_substitutionVariables(
            &self,
            object: Option<&AnyObject>,
            bindings: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> bool;

        #[unsafe(method(allowEvaluation))]
        #[unsafe(method_family = none)]
        pub fn allowEvaluation(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl NSPredicate {
    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>;
    );
}

impl DefaultRetained for NSPredicate {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// NSPredicateSupport.
#[cfg(feature = "NSArray")]
impl<ObjectType: Message> NSArray<ObjectType> {
    extern_methods!(
        #[unsafe(method(filteredArrayUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub fn filteredArrayUsingPredicate(
            &self,
            predicate: &NSPredicate,
        ) -> Retained<NSArray<ObjectType>>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSArray")]
impl<ObjectType: Message> NSMutableArray<ObjectType> {
    extern_methods!(
        #[unsafe(method(filterUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub fn filterUsingPredicate(&self, predicate: &NSPredicate);
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSSet")]
impl<ObjectType: Message> NSSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filteredSetUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub fn filteredSetUsingPredicate(
            &self,
            predicate: &NSPredicate,
        ) -> Retained<NSSet<ObjectType>>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSSet")]
impl<ObjectType: Message> NSMutableSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filterUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub fn filterUsingPredicate(&self, predicate: &NSPredicate);
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSOrderedSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filteredOrderedSetUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub fn filteredOrderedSetUsingPredicate(
            &self,
            p: &NSPredicate,
        ) -> Retained<NSOrderedSet<ObjectType>>;
    );
}

/// NSPredicateSupport.
#[cfg(feature = "NSOrderedSet")]
impl<ObjectType: Message> NSMutableOrderedSet<ObjectType> {
    extern_methods!(
        #[unsafe(method(filterUsingPredicate:))]
        #[unsafe(method_family = none)]
        pub fn filterUsingPredicate(&self, p: &NSPredicate);
    );
}
