Skip to content

Package: FeatureAwareComparator

FeatureAwareComparator

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.table.swt;
15:
16: import org.eclipse.emf.ecore.EStructuralFeature;
17:
18: /**
19: * Defines a comparator which knows about the feature that the compared values are stored in. This allows to use
20: * knowledge of the feature for the comparison.
21: *
22: * @param <T> The type of the objects comparable with this comparator
23: * @author Lucas Koehler
24: * @since 1.22
25: */
26: @FunctionalInterface
27: public interface FeatureAwareComparator<T> {
28:
29:         /**
30:          * Compares two values of the given feature.
31:          *
32:          * @param feature The {@link EStructuralFeature} containing the values
33:          * @param leftValue Left value
34:          * @param rightValue Right Value
35:          * @return a negative number if the left value is less than the right value;
36:          * the value <code>0</code> if the left value is equal to the right value;
37:          * a positive number if the left value is greater than the right value.
38:          * Thereby, <code>null</code> input values are treated as bigger than any other non-null value
39:          * @see java.util.Comparator#compare(Object, Object)
40:          */
41:         int compare(EStructuralFeature feature, T leftValue, T rightValue);
42: }