TableItemComparator.java revision 10a3ed3d5af2cbfbec2b35405d8d9420a9bf8776
1/*******************************************************************************
2 * Copyright (c) Copyright (c) Copyright (c) 2009, 2012 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.internal.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 */
21class TableItemComparator implements Comparator<ITableItem> {
22
23	private final Comparator<ICoverageNode> comparator;
24
25	TableItemComparator(final Comparator<ICoverageNode> comparator) {
26		this.comparator = comparator;
27	}
28
29	public int compare(final ITableItem i1, final ITableItem i2) {
30		return comparator.compare(i1.getNode(), i2.getNode());
31	}
32
33}