package com.atlassian.bitbucket.mesh.git.gc;

import com.atlassian.bitbucket.mesh.git.AbstractParameters;
import com.atlassian.bitbucket.mesh.repository.Repository;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

public class GarbageCollectionParameters extends AbstractParameters {

    private final int added;
    private final int deleted;
    private final Repository repository;
    private final boolean staleOnly;
    private final int updated;

    private GarbageCollectionParameters(Builder builder) {
        super(builder);

        added = builder.added;
        deleted = builder.deleted;
        repository = requireNonNull(builder.repository, "repository");
        staleOnly = builder.staleOnly;
        updated = builder.updated;
    }

    public int getAdded() {
        return added;
    }

    public int getDeleted() {
        return deleted;
    }

    @Nonnull
    public Repository getRepository() {
        return repository;
    }

    public int getUpdated() {
        return updated;
    }

    public boolean isStaleOnly() {
        return staleOnly;
    }

    public static class Builder extends AbstractBuilder<Builder, GarbageCollectionParameters> {

        private final Repository repository;

        private int added;
        private int deleted;
        private boolean staleOnly;
        private int updated;

        public Builder(@Nonnull Repository repository) {
            this.repository = requireNonNull(repository, "repository");
        }

        @Nonnull
        public Builder added(int value) {
            added = value;

            return this;
        }

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

        @Nonnull
        public Builder deleted(int value) {
            deleted = value;

            return this;
        }

        @Nonnull
        public Builder staleOnly(boolean value) {
            staleOnly = value;

            return this;
        }

        @Nonnull
        public Builder updated(int value) {
            updated = value;

            return this;
        }

        @Nonnull
        @Override
        protected Builder self() {
            return this;
        }
    }
}
