/* 
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

package dev.plexapi.sdk.models.operations;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.SpeakeasyMetadata;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Long;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.List;
import java.util.Objects;
import java.util.Optional;


public class GetSearchAllLibrariesRequest {

    /**
     * The search query term.
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=query")
    private String query;

    /**
     * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
     */
    @SpeakeasyMetadata("header:style=simple,explode=false,name=X-Plex-Client-Identifier")
    private Optional<String> clientID;

    /**
     * Limit the number of results returned.
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=limit")
    private Optional<Long> limit;

    /**
     * A comma-separated list of search types to include. Valid values are: movies, music, otherVideos, people, tv.
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=false,name=searchTypes")
    private Optional<? extends List<SearchTypes>> searchTypes;

    /**
     * Whether to include collections in the search results.
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeCollections")
    private Optional<? extends QueryParamIncludeCollections> includeCollections;

    /**
     * Whether to include external media in the search results.
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeExternalMedia")
    private Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia;

    @JsonCreator
    public GetSearchAllLibrariesRequest(
            String query,
            Optional<String> clientID,
            Optional<Long> limit,
            Optional<? extends List<SearchTypes>> searchTypes,
            Optional<? extends QueryParamIncludeCollections> includeCollections,
            Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia) {
        Utils.checkNotNull(query, "query");
        Utils.checkNotNull(clientID, "clientID");
        Utils.checkNotNull(limit, "limit");
        Utils.checkNotNull(searchTypes, "searchTypes");
        Utils.checkNotNull(includeCollections, "includeCollections");
        Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
        this.query = query;
        this.clientID = clientID;
        this.limit = limit;
        this.searchTypes = searchTypes;
        this.includeCollections = includeCollections;
        this.includeExternalMedia = includeExternalMedia;
    }
    
    public GetSearchAllLibrariesRequest(
            String query) {
        this(query, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
    }

    /**
     * The search query term.
     */
    @JsonIgnore
    public String query() {
        return query;
    }

    /**
     * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
     */
    @JsonIgnore
    public Optional<String> clientID() {
        return clientID;
    }

    /**
     * Limit the number of results returned.
     */
    @JsonIgnore
    public Optional<Long> limit() {
        return limit;
    }

    /**
     * A comma-separated list of search types to include. Valid values are: movies, music, otherVideos, people, tv.
     * 
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<List<SearchTypes>> searchTypes() {
        return (Optional<List<SearchTypes>>) searchTypes;
    }

    /**
     * Whether to include collections in the search results.
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<QueryParamIncludeCollections> includeCollections() {
        return (Optional<QueryParamIncludeCollections>) includeCollections;
    }

    /**
     * Whether to include external media in the search results.
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<QueryParamIncludeExternalMedia> includeExternalMedia() {
        return (Optional<QueryParamIncludeExternalMedia>) includeExternalMedia;
    }

    public final static Builder builder() {
        return new Builder();
    }

    /**
     * The search query term.
     */
    public GetSearchAllLibrariesRequest withQuery(String query) {
        Utils.checkNotNull(query, "query");
        this.query = query;
        return this;
    }

    /**
     * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
     */
    public GetSearchAllLibrariesRequest withClientID(String clientID) {
        Utils.checkNotNull(clientID, "clientID");
        this.clientID = Optional.ofNullable(clientID);
        return this;
    }

    /**
     * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
     */
    public GetSearchAllLibrariesRequest withClientID(Optional<String> clientID) {
        Utils.checkNotNull(clientID, "clientID");
        this.clientID = clientID;
        return this;
    }

    /**
     * Limit the number of results returned.
     */
    public GetSearchAllLibrariesRequest withLimit(long limit) {
        Utils.checkNotNull(limit, "limit");
        this.limit = Optional.ofNullable(limit);
        return this;
    }

    /**
     * Limit the number of results returned.
     */
    public GetSearchAllLibrariesRequest withLimit(Optional<Long> limit) {
        Utils.checkNotNull(limit, "limit");
        this.limit = limit;
        return this;
    }

    /**
     * A comma-separated list of search types to include. Valid values are: movies, music, otherVideos, people, tv.
     * 
     */
    public GetSearchAllLibrariesRequest withSearchTypes(List<SearchTypes> searchTypes) {
        Utils.checkNotNull(searchTypes, "searchTypes");
        this.searchTypes = Optional.ofNullable(searchTypes);
        return this;
    }

    /**
     * A comma-separated list of search types to include. Valid values are: movies, music, otherVideos, people, tv.
     * 
     */
    public GetSearchAllLibrariesRequest withSearchTypes(Optional<? extends List<SearchTypes>> searchTypes) {
        Utils.checkNotNull(searchTypes, "searchTypes");
        this.searchTypes = searchTypes;
        return this;
    }

    /**
     * Whether to include collections in the search results.
     */
    public GetSearchAllLibrariesRequest withIncludeCollections(QueryParamIncludeCollections includeCollections) {
        Utils.checkNotNull(includeCollections, "includeCollections");
        this.includeCollections = Optional.ofNullable(includeCollections);
        return this;
    }

    /**
     * Whether to include collections in the search results.
     */
    public GetSearchAllLibrariesRequest withIncludeCollections(Optional<? extends QueryParamIncludeCollections> includeCollections) {
        Utils.checkNotNull(includeCollections, "includeCollections");
        this.includeCollections = includeCollections;
        return this;
    }

    /**
     * Whether to include external media in the search results.
     */
    public GetSearchAllLibrariesRequest withIncludeExternalMedia(QueryParamIncludeExternalMedia includeExternalMedia) {
        Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
        this.includeExternalMedia = Optional.ofNullable(includeExternalMedia);
        return this;
    }

    /**
     * Whether to include external media in the search results.
     */
    public GetSearchAllLibrariesRequest withIncludeExternalMedia(Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia) {
        Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
        this.includeExternalMedia = includeExternalMedia;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GetSearchAllLibrariesRequest other = (GetSearchAllLibrariesRequest) o;
        return 
            Objects.deepEquals(this.query, other.query) &&
            Objects.deepEquals(this.clientID, other.clientID) &&
            Objects.deepEquals(this.limit, other.limit) &&
            Objects.deepEquals(this.searchTypes, other.searchTypes) &&
            Objects.deepEquals(this.includeCollections, other.includeCollections) &&
            Objects.deepEquals(this.includeExternalMedia, other.includeExternalMedia);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            query,
            clientID,
            limit,
            searchTypes,
            includeCollections,
            includeExternalMedia);
    }
    
    @Override
    public String toString() {
        return Utils.toString(GetSearchAllLibrariesRequest.class,
                "query", query,
                "clientID", clientID,
                "limit", limit,
                "searchTypes", searchTypes,
                "includeCollections", includeCollections,
                "includeExternalMedia", includeExternalMedia);
    }
    
    public final static class Builder {
 
        private String query;
 
        private Optional<String> clientID = Optional.empty();
 
        private Optional<Long> limit = Optional.empty();
 
        private Optional<? extends List<SearchTypes>> searchTypes = Optional.empty();
 
        private Optional<? extends QueryParamIncludeCollections> includeCollections;
 
        private Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia;  
        
        private Builder() {
          // force use of static builder() method
        }

        /**
         * The search query term.
         */
        public Builder query(String query) {
            Utils.checkNotNull(query, "query");
            this.query = query;
            return this;
        }

        /**
         * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
         */
        public Builder clientID(String clientID) {
            Utils.checkNotNull(clientID, "clientID");
            this.clientID = Optional.ofNullable(clientID);
            return this;
        }

        /**
         * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
         */
        public Builder clientID(Optional<String> clientID) {
            Utils.checkNotNull(clientID, "clientID");
            this.clientID = clientID;
            return this;
        }

        /**
         * Limit the number of results returned.
         */
        public Builder limit(long limit) {
            Utils.checkNotNull(limit, "limit");
            this.limit = Optional.ofNullable(limit);
            return this;
        }

        /**
         * Limit the number of results returned.
         */
        public Builder limit(Optional<Long> limit) {
            Utils.checkNotNull(limit, "limit");
            this.limit = limit;
            return this;
        }

        /**
         * A comma-separated list of search types to include. Valid values are: movies, music, otherVideos, people, tv.
         * 
         */
        public Builder searchTypes(List<SearchTypes> searchTypes) {
            Utils.checkNotNull(searchTypes, "searchTypes");
            this.searchTypes = Optional.ofNullable(searchTypes);
            return this;
        }

        /**
         * A comma-separated list of search types to include. Valid values are: movies, music, otherVideos, people, tv.
         * 
         */
        public Builder searchTypes(Optional<? extends List<SearchTypes>> searchTypes) {
            Utils.checkNotNull(searchTypes, "searchTypes");
            this.searchTypes = searchTypes;
            return this;
        }

        /**
         * Whether to include collections in the search results.
         */
        public Builder includeCollections(QueryParamIncludeCollections includeCollections) {
            Utils.checkNotNull(includeCollections, "includeCollections");
            this.includeCollections = Optional.ofNullable(includeCollections);
            return this;
        }

        /**
         * Whether to include collections in the search results.
         */
        public Builder includeCollections(Optional<? extends QueryParamIncludeCollections> includeCollections) {
            Utils.checkNotNull(includeCollections, "includeCollections");
            this.includeCollections = includeCollections;
            return this;
        }

        /**
         * Whether to include external media in the search results.
         */
        public Builder includeExternalMedia(QueryParamIncludeExternalMedia includeExternalMedia) {
            Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
            this.includeExternalMedia = Optional.ofNullable(includeExternalMedia);
            return this;
        }

        /**
         * Whether to include external media in the search results.
         */
        public Builder includeExternalMedia(Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia) {
            Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
            this.includeExternalMedia = includeExternalMedia;
            return this;
        }
        
        public GetSearchAllLibrariesRequest build() {
            if (includeCollections == null) {
                includeCollections = _SINGLETON_VALUE_IncludeCollections.value();
            }
            if (includeExternalMedia == null) {
                includeExternalMedia = _SINGLETON_VALUE_IncludeExternalMedia.value();
            }            return new GetSearchAllLibrariesRequest(
                query,
                clientID,
                limit,
                searchTypes,
                includeCollections,
                includeExternalMedia);
        }

        private static final LazySingletonValue<Optional<? extends QueryParamIncludeCollections>> _SINGLETON_VALUE_IncludeCollections =
                new LazySingletonValue<>(
                        "includeCollections",
                        "0",
                        new TypeReference<Optional<? extends QueryParamIncludeCollections>>() {});

        private static final LazySingletonValue<Optional<? extends QueryParamIncludeExternalMedia>> _SINGLETON_VALUE_IncludeExternalMedia =
                new LazySingletonValue<>(
                        "includeExternalMedia",
                        "0",
                        new TypeReference<Optional<? extends QueryParamIncludeExternalMedia>>() {});
    }
}

