berehovskyi / apex-validate

A lightweight Apex library that helps with validating arguments. Provides an easy way to follow a fail-fast principle and a design-by-contract programming approach.
MIT License
5 stars 1 forks source link

Ambiguous method signature: void notEmpty(List<WorkOrder>) #1

Open ILambuRI opened 3 weeks ago

ILambuRI commented 3 weeks ago

Hey, thx for your great lightweight library 👍

I got this error: Ambiguous method signature: void notEmpty(List)

I commented out this code to fix it:

// !!! Commented out due to error: Ambiguous method signature: void notEmpty(List<WorkOrder>) !!!
//    /**
//     * @description Checks that the argument `iterable` is not empty.
//     *
//     * @param iterable the iterable to check for emptiness
//     *
//     * @throws IllegalArgumentException if `iterable` is empty with the default exception message
//     * 'Argument iterable is empty'
//     * @throws NullPointerException if `iterable` is null with the default exception message 'Argument object is null'
//     *
//     * @see avlib_Validate.noNullElements
//     *
//     * @example
//     * Validate.notEmpty(someIterable);
//     * Validate.notEmpty((Iterable<String>) someStringSet);
//     */
//    public static void notEmpty(final Iterable<Object> iterable) {
//        notEmpty(iterable, Label.avlib_ErrorMessage_EmptyIterable);
//    }
//
//    /**
//     * @description Checks that the argument `iterable` is not empty.
//     *
//     * @param iterable the iterable to check for emptiness
//     * @param message the required custom exception message
//     *
//     * @throws IllegalArgumentException if `iterable` is empty with the custom exception `message`
//     * @throws NullPointerException if `iterable` is null with the default exception message 'Argument object is null'
//     * @throws NullPointerException if `message` is null with the default exception message
//     * 'Exception message cannot be null'
//     *
//     * @see avlib_Validate.noNullElements
//     *
//     * @example
//     * Validate.notEmpty(someIterable, 'The iterable cannot be empty');
//     * Validate.notEmpty((Iterable<String>) someStringSet, 'The set cannot be empty');
//     */
//    public static void notEmpty(final Iterable<Object> iterable, final String message) {
//        notEmpty(iterable, message, null);
//    }
//
//    /**
//     * @description Checks that the argument `iterable` is not empty.
//     *
//     * @param iterable the iterable to check for emptiness
//     * @param message the required formatted exception message
//     * @param arguments the optional values for the formatted exception message
//     *
//     * @throws IllegalArgumentException if `iterable` is empty with the custom exception `message`
//     * @throws NullPointerException if `iterable` is null with the default exception message 'Argument object is null'
//     * @throws NullPointerException if `message` is null with the default exception message
//     * 'Exception message cannot be null'
//     *
//     * @see avlib_Validate.noNullElements
//     *
//     * @example
//     * Validate.notEmpty(
//     *     someIterable,
//     *     'The iterable {0} cannot be empty',
//     *     new List<String>{ 'someIterable' }
//     * );
//     */
//    public static void notEmpty(final Iterable<Object> iterable, final String message, final List<Object> arguments) {
//        notNull(iterable);
//        isTrue(iterable.iterator().hasNext(), message, arguments);
//    }
// !!! Commented out due to error: Ambiguous method signature: void notEmpty(List<WorkOrder>) !!!
berehovskyi commented 3 weeks ago

Hi @ILambuRI,

Can you provide some context? Are you facing a compile error, or is this a runtime exception? What are you passing to the Validate.notEmpty method?