
package de.ivu.elect.presentation.ui;

import java.util.Comparator;
import java.util.Map;

import de.ivu.elect.business.ui.boundary.UITableColumnOrderComparator;
import de.ivu.elect.business.ui.entity.UITableColumnOrder;
import de.ivu.elect.jee.presentation.dynamictable.ColumnEntry;

public class ColumnEntryByUITableColumnOrderComparator implements Comparator<ColumnEntry< ? >> {

  private static final UITableColumnOrderComparator UI_TABLE_COLUMN_ORDER_COMPARATOR = new UITableColumnOrderComparator();

  private final Map<String, UITableColumnOrder> uiTableColumnOrderByName;

  public ColumnEntryByUITableColumnOrderComparator(Map<String, UITableColumnOrder> uiTableColumnOrderByName) {
    super();

    this.uiTableColumnOrderByName = uiTableColumnOrderByName;
  }

  @Override
  public int compare(ColumnEntry< ? > one, ColumnEntry< ? > another) {
    return UI_TABLE_COLUMN_ORDER_COMPARATOR.compare(uiTableColumnOrderByName.get(one.getName()), uiTableColumnOrderByName.get(another.getName()));
  }
}
