package com.atlassian.bitbucket.mesh.management;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.security.PublicKey;

import static java.util.Objects.requireNonNull;

public class ProvisionParameters {

    private final String nodeId;
    private final PublicKey publicKey;

    private ProvisionParameters(Builder builder) {
        nodeId = builder.nodeId;
        publicKey = builder.publicKey;
    }

    /**
     * @return the node ID
     * @since 1.2
     */
    @Nullable
    public String getNodeId() {
        return nodeId;
    }

    @Nonnull
    public PublicKey getPublicKey() {
        return publicKey;
    }

    public static class Builder {

        private final PublicKey publicKey;

        private String nodeId;

        public Builder(@Nonnull PublicKey publicKey) {
            this.publicKey = requireNonNull(publicKey, "publicKey");
        }

        /**
         * @param value the node ID
         * @return the builder
         * @since 1.2
         */
        public Builder nodeId(@Nullable String value) {
            nodeId = value;
            return this;
        }

        @Nonnull
        public ProvisionParameters build() {
            return new ProvisionParameters(this);
        }
    }
}
