package com.atlassian.bitbucket.repository;

import javax.annotation.Nonnull;

import static com.atlassian.bitbucket.repository.StandardRefType.TAG;

public class SimpleTag extends SimpleRef implements Tag {

    private final String hash;

    private SimpleTag(@Nonnull Builder builder) {
        super(builder, TAG);

        hash = builder.hash;
    }

    @Override
    public String getHash() {
        return hash;
    }

    @Nonnull
    @Override
    protected String fieldsToString() {
        return super.fieldsToString() + ", hash=" + getHash();
    }

    public static class Builder extends AbstractRefBuilder<Builder, Tag> {

        private String hash;

        public Builder() {
        }

        public Builder(Tag ref) {
            super(ref);

            hash = ref.getHash();
        }

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

        public Builder hash(String value) {
            hash = value;

            return this;
        }

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