package com.centzy.badger.client;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;

import javax.annotation.Nullable;
import java.util.List;

/**
 * @author Peter Edge (peter@locality.com).
 */
public class ProtoTagValue {

  private final ImmutableList<Integer> tag;
  private final ImmutableList<Integer> repeatedTagIndexes;

  public ProtoTagValue(List<Integer> tag, @Nullable List<Integer> repeatedTagIndexes) {
    this.tag = ImmutableList.copyOf(tag);
    this.repeatedTagIndexes = repeatedTagIndexes == null ? null : ImmutableList.copyOf(repeatedTagIndexes);
  }

  public ImmutableList<Integer> getTag() {
    return tag;
  }

  public ImmutableList<Integer> getRepeatedTagIndexes() {
    return repeatedTagIndexes;
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(tag, repeatedTagIndexes);
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null || getClass() != obj.getClass()) {
      return false;
    }
    final ProtoTagValue other = (ProtoTagValue) obj;
    return Objects.equal(this.tag, other.tag) && Objects.equal(this.repeatedTagIndexes, other.repeatedTagIndexes);
  }

  @Override
  public String toString() {
    return Objects.toStringHelper(this)
        .add("tag", tag)
        .add("repeatedTagIndexes", repeatedTagIndexes)
        .toString();
  }
}
