/* 
 * 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.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.Override;
import java.lang.String;
import java.util.List;
import java.util.Objects;
import java.util.Optional;


public class Friend {

    /**
     * The account email address
     */
    @JsonProperty("email")
    private String email;

    /**
     * The account full name
     */
    @JsonInclude(Include.ALWAYS)
    @JsonProperty("friendlyName")
    private Optional<String> friendlyName;

    /**
     * If the account is a Plex Home user
     */
    @JsonProperty("home")
    private boolean home;

    /**
     * The Plex account ID
     */
    @JsonProperty("id")
    private int id;

    /**
     * If the account is a Plex Home managed user
     */
    @JsonInclude(Include.NON_ABSENT)
    @JsonProperty("restricted")
    private Optional<Boolean> restricted;

    @JsonProperty("sharedServers")
    private List<SharedServers> sharedServers;

    @JsonProperty("sharedSources")
    private List<SharedSources> sharedSources;

    /**
     * Current friend request status
     */
    @JsonProperty("status")
    private Status status;

    /**
     * URL of the account thumbnail
     */
    @JsonProperty("thumb")
    private String thumb;

    /**
     * The title of the account (username or friendly name)
     */
    @JsonProperty("title")
    private String title;

    /**
     * The account username
     */
    @JsonProperty("username")
    private String username;

    /**
     * The account Universally Unique Identifier (UUID)
     */
    @JsonProperty("uuid")
    private String uuid;

    @JsonCreator
    public Friend(
            @JsonProperty("email") String email,
            @JsonProperty("friendlyName") Optional<String> friendlyName,
            @JsonProperty("home") boolean home,
            @JsonProperty("id") int id,
            @JsonProperty("restricted") Optional<Boolean> restricted,
            @JsonProperty("sharedServers") List<SharedServers> sharedServers,
            @JsonProperty("sharedSources") List<SharedSources> sharedSources,
            @JsonProperty("status") Status status,
            @JsonProperty("thumb") String thumb,
            @JsonProperty("title") String title,
            @JsonProperty("username") String username,
            @JsonProperty("uuid") String uuid) {
        Utils.checkNotNull(email, "email");
        Utils.checkNotNull(friendlyName, "friendlyName");
        Utils.checkNotNull(home, "home");
        Utils.checkNotNull(id, "id");
        Utils.checkNotNull(restricted, "restricted");
        Utils.checkNotNull(sharedServers, "sharedServers");
        Utils.checkNotNull(sharedSources, "sharedSources");
        Utils.checkNotNull(status, "status");
        Utils.checkNotNull(thumb, "thumb");
        Utils.checkNotNull(title, "title");
        Utils.checkNotNull(username, "username");
        Utils.checkNotNull(uuid, "uuid");
        this.email = email;
        this.friendlyName = friendlyName;
        this.home = home;
        this.id = id;
        this.restricted = restricted;
        this.sharedServers = sharedServers;
        this.sharedSources = sharedSources;
        this.status = status;
        this.thumb = thumb;
        this.title = title;
        this.username = username;
        this.uuid = uuid;
    }
    
    public Friend(
            String email,
            boolean home,
            int id,
            List<SharedServers> sharedServers,
            List<SharedSources> sharedSources,
            Status status,
            String thumb,
            String title,
            String username,
            String uuid) {
        this(email, Optional.empty(), home, id, Optional.empty(), sharedServers, sharedSources, status, thumb, title, username, uuid);
    }

    /**
     * The account email address
     */
    @JsonIgnore
    public String email() {
        return email;
    }

    /**
     * The account full name
     */
    @JsonIgnore
    public Optional<String> friendlyName() {
        return friendlyName;
    }

    /**
     * If the account is a Plex Home user
     */
    @JsonIgnore
    public boolean home() {
        return home;
    }

    /**
     * The Plex account ID
     */
    @JsonIgnore
    public int id() {
        return id;
    }

    /**
     * If the account is a Plex Home managed user
     */
    @JsonIgnore
    public Optional<Boolean> restricted() {
        return restricted;
    }

    @JsonIgnore
    public List<SharedServers> sharedServers() {
        return sharedServers;
    }

    @JsonIgnore
    public List<SharedSources> sharedSources() {
        return sharedSources;
    }

    /**
     * Current friend request status
     */
    @JsonIgnore
    public Status status() {
        return status;
    }

    /**
     * URL of the account thumbnail
     */
    @JsonIgnore
    public String thumb() {
        return thumb;
    }

    /**
     * The title of the account (username or friendly name)
     */
    @JsonIgnore
    public String title() {
        return title;
    }

    /**
     * The account username
     */
    @JsonIgnore
    public String username() {
        return username;
    }

    /**
     * The account Universally Unique Identifier (UUID)
     */
    @JsonIgnore
    public String uuid() {
        return uuid;
    }

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

    /**
     * The account email address
     */
    public Friend withEmail(String email) {
        Utils.checkNotNull(email, "email");
        this.email = email;
        return this;
    }

    /**
     * The account full name
     */
    public Friend withFriendlyName(String friendlyName) {
        Utils.checkNotNull(friendlyName, "friendlyName");
        this.friendlyName = Optional.ofNullable(friendlyName);
        return this;
    }

    /**
     * The account full name
     */
    public Friend withFriendlyName(Optional<String> friendlyName) {
        Utils.checkNotNull(friendlyName, "friendlyName");
        this.friendlyName = friendlyName;
        return this;
    }

    /**
     * If the account is a Plex Home user
     */
    public Friend withHome(boolean home) {
        Utils.checkNotNull(home, "home");
        this.home = home;
        return this;
    }

    /**
     * The Plex account ID
     */
    public Friend withId(int id) {
        Utils.checkNotNull(id, "id");
        this.id = id;
        return this;
    }

    /**
     * If the account is a Plex Home managed user
     */
    public Friend withRestricted(boolean restricted) {
        Utils.checkNotNull(restricted, "restricted");
        this.restricted = Optional.ofNullable(restricted);
        return this;
    }

    /**
     * If the account is a Plex Home managed user
     */
    public Friend withRestricted(Optional<Boolean> restricted) {
        Utils.checkNotNull(restricted, "restricted");
        this.restricted = restricted;
        return this;
    }

    public Friend withSharedServers(List<SharedServers> sharedServers) {
        Utils.checkNotNull(sharedServers, "sharedServers");
        this.sharedServers = sharedServers;
        return this;
    }

    public Friend withSharedSources(List<SharedSources> sharedSources) {
        Utils.checkNotNull(sharedSources, "sharedSources");
        this.sharedSources = sharedSources;
        return this;
    }

    /**
     * Current friend request status
     */
    public Friend withStatus(Status status) {
        Utils.checkNotNull(status, "status");
        this.status = status;
        return this;
    }

    /**
     * URL of the account thumbnail
     */
    public Friend withThumb(String thumb) {
        Utils.checkNotNull(thumb, "thumb");
        this.thumb = thumb;
        return this;
    }

    /**
     * The title of the account (username or friendly name)
     */
    public Friend withTitle(String title) {
        Utils.checkNotNull(title, "title");
        this.title = title;
        return this;
    }

    /**
     * The account username
     */
    public Friend withUsername(String username) {
        Utils.checkNotNull(username, "username");
        this.username = username;
        return this;
    }

    /**
     * The account Universally Unique Identifier (UUID)
     */
    public Friend withUuid(String uuid) {
        Utils.checkNotNull(uuid, "uuid");
        this.uuid = uuid;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Friend other = (Friend) o;
        return 
            Objects.deepEquals(this.email, other.email) &&
            Objects.deepEquals(this.friendlyName, other.friendlyName) &&
            Objects.deepEquals(this.home, other.home) &&
            Objects.deepEquals(this.id, other.id) &&
            Objects.deepEquals(this.restricted, other.restricted) &&
            Objects.deepEquals(this.sharedServers, other.sharedServers) &&
            Objects.deepEquals(this.sharedSources, other.sharedSources) &&
            Objects.deepEquals(this.status, other.status) &&
            Objects.deepEquals(this.thumb, other.thumb) &&
            Objects.deepEquals(this.title, other.title) &&
            Objects.deepEquals(this.username, other.username) &&
            Objects.deepEquals(this.uuid, other.uuid);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            email,
            friendlyName,
            home,
            id,
            restricted,
            sharedServers,
            sharedSources,
            status,
            thumb,
            title,
            username,
            uuid);
    }
    
    @Override
    public String toString() {
        return Utils.toString(Friend.class,
                "email", email,
                "friendlyName", friendlyName,
                "home", home,
                "id", id,
                "restricted", restricted,
                "sharedServers", sharedServers,
                "sharedSources", sharedSources,
                "status", status,
                "thumb", thumb,
                "title", title,
                "username", username,
                "uuid", uuid);
    }
    
    public final static class Builder {
 
        private String email;
 
        private Optional<String> friendlyName = Optional.empty();
 
        private Boolean home;
 
        private Integer id;
 
        private Optional<Boolean> restricted;
 
        private List<SharedServers> sharedServers;
 
        private List<SharedSources> sharedSources;
 
        private Status status;
 
        private String thumb;
 
        private String title;
 
        private String username;
 
        private String uuid;  
        
        private Builder() {
          // force use of static builder() method
        }

        /**
         * The account email address
         */
        public Builder email(String email) {
            Utils.checkNotNull(email, "email");
            this.email = email;
            return this;
        }

        /**
         * The account full name
         */
        public Builder friendlyName(String friendlyName) {
            Utils.checkNotNull(friendlyName, "friendlyName");
            this.friendlyName = Optional.ofNullable(friendlyName);
            return this;
        }

        /**
         * The account full name
         */
        public Builder friendlyName(Optional<String> friendlyName) {
            Utils.checkNotNull(friendlyName, "friendlyName");
            this.friendlyName = friendlyName;
            return this;
        }

        /**
         * If the account is a Plex Home user
         */
        public Builder home(boolean home) {
            Utils.checkNotNull(home, "home");
            this.home = home;
            return this;
        }

        /**
         * The Plex account ID
         */
        public Builder id(int id) {
            Utils.checkNotNull(id, "id");
            this.id = id;
            return this;
        }

        /**
         * If the account is a Plex Home managed user
         */
        public Builder restricted(boolean restricted) {
            Utils.checkNotNull(restricted, "restricted");
            this.restricted = Optional.ofNullable(restricted);
            return this;
        }

        /**
         * If the account is a Plex Home managed user
         */
        public Builder restricted(Optional<Boolean> restricted) {
            Utils.checkNotNull(restricted, "restricted");
            this.restricted = restricted;
            return this;
        }

        public Builder sharedServers(List<SharedServers> sharedServers) {
            Utils.checkNotNull(sharedServers, "sharedServers");
            this.sharedServers = sharedServers;
            return this;
        }

        public Builder sharedSources(List<SharedSources> sharedSources) {
            Utils.checkNotNull(sharedSources, "sharedSources");
            this.sharedSources = sharedSources;
            return this;
        }

        /**
         * Current friend request status
         */
        public Builder status(Status status) {
            Utils.checkNotNull(status, "status");
            this.status = status;
            return this;
        }

        /**
         * URL of the account thumbnail
         */
        public Builder thumb(String thumb) {
            Utils.checkNotNull(thumb, "thumb");
            this.thumb = thumb;
            return this;
        }

        /**
         * The title of the account (username or friendly name)
         */
        public Builder title(String title) {
            Utils.checkNotNull(title, "title");
            this.title = title;
            return this;
        }

        /**
         * The account username
         */
        public Builder username(String username) {
            Utils.checkNotNull(username, "username");
            this.username = username;
            return this;
        }

        /**
         * The account Universally Unique Identifier (UUID)
         */
        public Builder uuid(String uuid) {
            Utils.checkNotNull(uuid, "uuid");
            this.uuid = uuid;
            return this;
        }
        
        public Friend build() {
            if (restricted == null) {
                restricted = _SINGLETON_VALUE_Restricted.value();
            }            return new Friend(
                email,
                friendlyName,
                home,
                id,
                restricted,
                sharedServers,
                sharedSources,
                status,
                thumb,
                title,
                username,
                uuid);
        }

        private static final LazySingletonValue<Optional<Boolean>> _SINGLETON_VALUE_Restricted =
                new LazySingletonValue<>(
                        "restricted",
                        "false",
                        new TypeReference<Optional<Boolean>>() {});
    }
}

