// Path: src/main/java/com/verifalia/api/common/Utils.java
// public class Utils {
//     /**
//      * Generates URI for HTTP request.
//      *
//      * @param paramMap Map with variable names and values to be passed when making URI for http request.
//      * @return URI URI for HTTP request based on the input parameters.
//      */
//     public static URI getHttpUri(Map<String, String> paramMap) {
//         URIBuilder builder = new URIBuilder();
//         try {
//             if (nonNull(paramMap) && paramMap.size() > 0) {
//                 Iterator<String> paramMapIter = paramMap.keySet().iterator();
//                 while (paramMapIter.hasNext()) {
//                     String paramKey = paramMapIter.next();
//                     String paramValue = paramMap.get(paramKey);
//                     if (!StringUtils.isEmpty(paramValue)) {
//                         builder.setParameter(paramKey, paramValue);
//                     }
//                 }
//             }
// 
//             return builder.build();
//         } catch (URISyntaxException e) {
//             return null;
//         }
//     }
// 
//     /**
//      * Converts local date to string based on the input format.
//      *
//      * @param localDate  LocalDate object which needs to be formatted.
//      * @param dateFormat Date format in which the local date object needs to be formatted.
//      * @return String Converted local date to string as per the input format.
//      */
//     public static String convertLocalDateToString(LocalDate localDate, String dateFormat) {
//         if (nonNull(localDate)) {
//             return localDate.format(DateTimeFormatter.ofPattern(dateFormat));
//         }
//         return StringUtils.EMPTY;
//     }
// }


import com.verifalia.api.common.Utils;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import java.time.LocalDate;
import java.util.ArrayList;
/*
 * Verifalia - Email list cleaning and real-time email verification service
 * https://verifalia.com/
 * support@verifalia.com
 *
 * Copyright (c) 2005-2020 Cobisi Research
 *
 * Cobisi Research
 * Via Prima Strada, 35
 * 35129, Padova
 * Italy - European Union
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.verifalia.api.common.filters;



/**
 * A filter predicate used to filter dates between two optional values.
 */
@Getter
@Setter
public class DateBetweenPredicate extends DateFilterPredicate {
    /**
     * The minimum date to be included in the filter.
     */
    private LocalDate since;

    /**
     * The maximum date to be included in the filter.
     */
    private LocalDate until;

    /**
     * Initializes a filter predicate used to filter dates between two optional values.
     *
     * @param since The minimum date to be included in the filter.
     * @param until The maximum date to be included in the filter.
     */
    public DateBetweenPredicate(final LocalDate since, final LocalDate until) {
        if (since == null && until == null) {
            throw new IllegalArgumentException("Both since and until are null.");
        }

        if (since != null && until != null) {
            if (since.isAfter(until)) {
                throw new IllegalArgumentException("Invalid predicate: since is after until.");
            }
        }

        this.setSince(since);
        this.setUntil(until);
    }

    @Override
    public FilterPredicateFragment[] serialize(@NonNull final String fieldName) {
        ArrayList<FilterPredicateFragment> result = new ArrayList<>();

        if (this.getSince() != null) {
// Path: src/main/java/com/verifalia/api/common/Utils.java
// public class Utils {
//     /**
//      * Generates URI for HTTP request.
//      *
//      * @param paramMap Map with variable names and values to be passed when making URI for http request.
//      * @return URI URI for HTTP request based on the input parameters.
//      */
//     public static URI getHttpUri(Map<String, String> paramMap) {
//         URIBuilder builder = new URIBuilder();
//         try {
//             if (nonNull(paramMap) && paramMap.size() > 0) {
//                 Iterator<String> paramMapIter = paramMap.keySet().iterator();
//                 while (paramMapIter.hasNext()) {
//                     String paramKey = paramMapIter.next();
//                     String paramValue = paramMap.get(paramKey);
//                     if (!StringUtils.isEmpty(paramValue)) {
//                         builder.setParameter(paramKey, paramValue);
//                     }
//                 }
//             }
// 
//             return builder.build();
//         } catch (URISyntaxException e) {
//             return null;
//         }
//     }
// 
//     /**
//      * Converts local date to string based on the input format.
//      *
//      * @param localDate  LocalDate object which needs to be formatted.
//      * @param dateFormat Date format in which the local date object needs to be formatted.
//      * @return String Converted local date to string as per the input format.
//      */
//     public static String convertLocalDateToString(LocalDate localDate, String dateFormat) {
//         if (nonNull(localDate)) {
//             return localDate.format(DateTimeFormatter.ofPattern(dateFormat));
//         }
//         return StringUtils.EMPTY;
//     }
// }


// Path: src/main/java/com/verifalia/api/common/filters/DateBetweenPredicate.java
import com.verifalia.api.common.Utils;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import java.time.LocalDate;
import java.util.ArrayList;

/*
 * Verifalia - Email list cleaning and real-time email verification service
 * https://verifalia.com/
 * support@verifalia.com
 *
 * Copyright (c) 2005-2020 Cobisi Research
 *
 * Cobisi Research
 * Via Prima Strada, 35
 * 35129, Padova
 * Italy - European Union
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.verifalia.api.common.filters;



/**
 * A filter predicate used to filter dates between two optional values.
 */
@Getter
@Setter
public class DateBetweenPredicate extends DateFilterPredicate {
    /**
     * The minimum date to be included in the filter.
     */
    private LocalDate since;

    /**
     * The maximum date to be included in the filter.
     */
    private LocalDate until;

    /**
     * Initializes a filter predicate used to filter dates between two optional values.
     *
     * @param since The minimum date to be included in the filter.
     * @param until The maximum date to be included in the filter.
     */
    public DateBetweenPredicate(final LocalDate since, final LocalDate until) {
        if (since == null && until == null) {
            throw new IllegalArgumentException("Both since and until are null.");
        }

        if (since != null && until != null) {
            if (since.isAfter(until)) {
                throw new IllegalArgumentException("Invalid predicate: since is after until.");
            }
        }

        this.setSince(since);
        this.setUntil(until);
    }

    @Override
    public FilterPredicateFragment[] serialize(@NonNull final String fieldName) {
        ArrayList<FilterPredicateFragment> result = new ArrayList<>();

        if (this.getSince() != null) {
            result.add(new FilterPredicateFragment(fieldName + ":since", Utils.convertLocalDateToString(this.getSince(), "yyyy-MM-dd")));