TableItemComparator.java
1/*******************************************************************************
2 * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Marc R. Hoffmann - initial API and implementation
10 *
11 *******************************************************************************/
12package org.jacoco.report.html.table;
13
14import java.util.Comparator;
15
16import org.jacoco.core.analysis.ICoverageNode;
17
18/**
19 * Adapter to sort table items based on their coverage nodes.
20 *
21 * @author Marc R. Hoffmann
22 * @version 0.4.1.20101007204400
23 */
24class TableItemComparator implements Comparator<ITableItem> {
25
26 private final Comparator<ICoverageNode> comparator;
27
28 TableItemComparator(final Comparator<ICoverageNode> comparator) {
29 this.comparator = comparator;
30 }
31
32 public int compare(final ITableItem i1, final ITableItem i2) {
33 return comparator.compare(i1.getNode(), i2.getNode());
34 }
35
36}