/* 
 * 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 dev.plexapi.sdk.utils.Utils;
import java.lang.Long;
import java.lang.Override;
import java.lang.String;
import java.util.Objects;
import java.util.Optional;


public class Billing {

    @JsonProperty("internalPaymentMethod")
    private InternalPaymentMethod internalPaymentMethod;

    @JsonInclude(Include.ALWAYS)
    @JsonProperty("paymentMethodId")
    private Optional<Long> paymentMethodId;

    @JsonCreator
    public Billing(
            @JsonProperty("internalPaymentMethod") InternalPaymentMethod internalPaymentMethod,
            @JsonProperty("paymentMethodId") Optional<Long> paymentMethodId) {
        Utils.checkNotNull(internalPaymentMethod, "internalPaymentMethod");
        Utils.checkNotNull(paymentMethodId, "paymentMethodId");
        this.internalPaymentMethod = internalPaymentMethod;
        this.paymentMethodId = paymentMethodId;
    }
    
    public Billing(
            InternalPaymentMethod internalPaymentMethod) {
        this(internalPaymentMethod, Optional.empty());
    }

    @JsonIgnore
    public InternalPaymentMethod internalPaymentMethod() {
        return internalPaymentMethod;
    }

    @JsonIgnore
    public Optional<Long> paymentMethodId() {
        return paymentMethodId;
    }

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

    public Billing withInternalPaymentMethod(InternalPaymentMethod internalPaymentMethod) {
        Utils.checkNotNull(internalPaymentMethod, "internalPaymentMethod");
        this.internalPaymentMethod = internalPaymentMethod;
        return this;
    }

    public Billing withPaymentMethodId(long paymentMethodId) {
        Utils.checkNotNull(paymentMethodId, "paymentMethodId");
        this.paymentMethodId = Optional.ofNullable(paymentMethodId);
        return this;
    }

    public Billing withPaymentMethodId(Optional<Long> paymentMethodId) {
        Utils.checkNotNull(paymentMethodId, "paymentMethodId");
        this.paymentMethodId = paymentMethodId;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Billing other = (Billing) o;
        return 
            Objects.deepEquals(this.internalPaymentMethod, other.internalPaymentMethod) &&
            Objects.deepEquals(this.paymentMethodId, other.paymentMethodId);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            internalPaymentMethod,
            paymentMethodId);
    }
    
    @Override
    public String toString() {
        return Utils.toString(Billing.class,
                "internalPaymentMethod", internalPaymentMethod,
                "paymentMethodId", paymentMethodId);
    }
    
    public final static class Builder {
 
        private InternalPaymentMethod internalPaymentMethod;
 
        private Optional<Long> paymentMethodId = Optional.empty();  
        
        private Builder() {
          // force use of static builder() method
        }

        public Builder internalPaymentMethod(InternalPaymentMethod internalPaymentMethod) {
            Utils.checkNotNull(internalPaymentMethod, "internalPaymentMethod");
            this.internalPaymentMethod = internalPaymentMethod;
            return this;
        }

        public Builder paymentMethodId(long paymentMethodId) {
            Utils.checkNotNull(paymentMethodId, "paymentMethodId");
            this.paymentMethodId = Optional.ofNullable(paymentMethodId);
            return this;
        }

        public Builder paymentMethodId(Optional<Long> paymentMethodId) {
            Utils.checkNotNull(paymentMethodId, "paymentMethodId");
            this.paymentMethodId = paymentMethodId;
            return this;
        }
        
        public Billing build() {
            return new Billing(
                internalPaymentMethod,
                paymentMethodId);
        }
    }
}

