package com.capgemini.reports;

import com.teamcenter.soa.client.model.strong.ItemRevision;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Helper class to compare compares two itemRevision by concatenating their properties item_id, item_revision_id,sequence_id, ex: 002605B1. *
 */
public class ItemRevisionComparator implements Comparator<ItemRevision>, Serializable {
  private static final long serialVersionUID = -1094043465048885249L;

  @Override
  public int compare(ItemRevision obj1, ItemRevision obj2) {
    String itemRevision1 = obj1.get_item_id() + obj1.get_item_revision_id() + obj1.get_sequence_id();
    String itemRevision2 = obj2.get_item_id() + obj2.get_item_revision_id() + obj2.get_sequence_id();
    return itemRevision1.compareTo(itemRevision2);
  }

}
