package com.capgemini.reports.definition.r26report;

import com.google.common.base.Joiner;
import com.teamcenter.soa.client.model.strong.ItemRevision;

public class Range {
  private int borneInf;
  private int borneSup;
  private ItemRevision itemRevion;
  private String revision;

  Range(ItemRevision revision, int borneInf, int borneSup) {
    this.itemRevion = revision;
    this.revision = revision.get_item_revision_id();
    this.borneInf = borneInf;
    this.borneSup = borneSup;
  }

  Range(String revision, int borneInf, int borneSup) {
    this.itemRevion = null;
    this.revision = revision;
    this.borneInf = borneInf;
    this.borneSup = borneSup;
  }

  @Override
  public String toString() {
    if (borneInf == borneSup) {
      return Integer.toString(borneInf);
    }
    else {
      return Joiner.on("-").join(Integer.toString(borneInf), Integer.toString(borneSup));
    }
  }

  ItemRevision getItemRevion() {
    return itemRevion;
  }

  public String getRevision() {
    return revision;
  }

  public void setRevision(String revision) {
    this.revision = revision;
  }

  int borneSup() {
    return borneSup;
  }

  int borneInf() {
    return borneInf;
  }

  public boolean isUp() {
    return borneSup == 2147483646;
  }
}
