All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.util.Comparator Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2011-2014 Fernando Petrola
 * 
 *  This file is part of Dragome SDK.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 ******************************************************************************/
package java.util;

import java.io.Serializable;
import java.util.function.Function;

public interface Comparator
{
	public int compare(T o1, T o2);
	public boolean equals(Object obj);

	public static > Comparator comparing(Function keyExtractor)
	{
		Objects.requireNonNull(keyExtractor);
		return (Comparator & Serializable) (c1, c2) -> keyExtractor.apply(c1).compareTo(keyExtractor.apply(c2));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy