/* 
 * 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.Integer;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Objects;
import java.util.Optional;


public class GetLibraryDetailsRequest {

    /**
     * Whether or not to include details for a section (types, filters, and sorts). 
     * Only exists for backwards compatibility, media providers other than the server libraries have it on always.
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeDetails")
    private Optional<? extends IncludeDetails> includeDetails;

    /**
     * The unique key of the Plex library. 
     * Note: This is unique in the context of the Plex server.
     * 
     */
    @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=sectionKey")
    private int sectionKey;

    @JsonCreator
    public GetLibraryDetailsRequest(
            Optional<? extends IncludeDetails> includeDetails,
            int sectionKey) {
        Utils.checkNotNull(includeDetails, "includeDetails");
        Utils.checkNotNull(sectionKey, "sectionKey");
        this.includeDetails = includeDetails;
        this.sectionKey = sectionKey;
    }
    
    public GetLibraryDetailsRequest(
            int sectionKey) {
        this(Optional.empty(), sectionKey);
    }

    /**
     * Whether or not to include details for a section (types, filters, and sorts). 
     * Only exists for backwards compatibility, media providers other than the server libraries have it on always.
     * 
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<IncludeDetails> includeDetails() {
        return (Optional<IncludeDetails>) includeDetails;
    }

    /**
     * The unique key of the Plex library. 
     * Note: This is unique in the context of the Plex server.
     * 
     */
    @JsonIgnore
    public int sectionKey() {
        return sectionKey;
    }

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

    /**
     * Whether or not to include details for a section (types, filters, and sorts). 
     * Only exists for backwards compatibility, media providers other than the server libraries have it on always.
     * 
     */
    public GetLibraryDetailsRequest withIncludeDetails(IncludeDetails includeDetails) {
        Utils.checkNotNull(includeDetails, "includeDetails");
        this.includeDetails = Optional.ofNullable(includeDetails);
        return this;
    }

    /**
     * Whether or not to include details for a section (types, filters, and sorts). 
     * Only exists for backwards compatibility, media providers other than the server libraries have it on always.
     * 
     */
    public GetLibraryDetailsRequest withIncludeDetails(Optional<? extends IncludeDetails> includeDetails) {
        Utils.checkNotNull(includeDetails, "includeDetails");
        this.includeDetails = includeDetails;
        return this;
    }

    /**
     * The unique key of the Plex library. 
     * Note: This is unique in the context of the Plex server.
     * 
     */
    public GetLibraryDetailsRequest withSectionKey(int sectionKey) {
        Utils.checkNotNull(sectionKey, "sectionKey");
        this.sectionKey = sectionKey;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GetLibraryDetailsRequest other = (GetLibraryDetailsRequest) o;
        return 
            Objects.deepEquals(this.includeDetails, other.includeDetails) &&
            Objects.deepEquals(this.sectionKey, other.sectionKey);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            includeDetails,
            sectionKey);
    }
    
    @Override
    public String toString() {
        return Utils.toString(GetLibraryDetailsRequest.class,
                "includeDetails", includeDetails,
                "sectionKey", sectionKey);
    }
    
    public final static class Builder {
 
        private Optional<? extends IncludeDetails> includeDetails;
 
        private Integer sectionKey;  
        
        private Builder() {
          // force use of static builder() method
        }

        /**
         * Whether or not to include details for a section (types, filters, and sorts). 
         * Only exists for backwards compatibility, media providers other than the server libraries have it on always.
         * 
         */
        public Builder includeDetails(IncludeDetails includeDetails) {
            Utils.checkNotNull(includeDetails, "includeDetails");
            this.includeDetails = Optional.ofNullable(includeDetails);
            return this;
        }

        /**
         * Whether or not to include details for a section (types, filters, and sorts). 
         * Only exists for backwards compatibility, media providers other than the server libraries have it on always.
         * 
         */
        public Builder includeDetails(Optional<? extends IncludeDetails> includeDetails) {
            Utils.checkNotNull(includeDetails, "includeDetails");
            this.includeDetails = includeDetails;
            return this;
        }

        /**
         * The unique key of the Plex library. 
         * Note: This is unique in the context of the Plex server.
         * 
         */
        public Builder sectionKey(int sectionKey) {
            Utils.checkNotNull(sectionKey, "sectionKey");
            this.sectionKey = sectionKey;
            return this;
        }
        
        public GetLibraryDetailsRequest build() {
            if (includeDetails == null) {
                includeDetails = _SINGLETON_VALUE_IncludeDetails.value();
            }            return new GetLibraryDetailsRequest(
                includeDetails,
                sectionKey);
        }

        private static final LazySingletonValue<Optional<? extends IncludeDetails>> _SINGLETON_VALUE_IncludeDetails =
                new LazySingletonValue<>(
                        "includeDetails",
                        "0",
                        new TypeReference<Optional<? extends IncludeDetails>>() {});
    }
}

