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

org.eclipse.xtext.xbase.lib.ComparableExtensions Maven / Gradle / Ivy

There is a newer version: 2.4.3
Show newest version
/*******************************************************************************
 * Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.xbase.lib;

import com.google.common.annotations.GwtCompatible;


/**
 * This is an extension library for {@link Comparable comparables}.
 * 
 * @author Sven Efftinge - Initial contribution and API
 */
@GwtCompatible public class ComparableExtensions {

	/**
	 * The comparison operator less than.
	 * 
	 * @param left
	 *            a comparable
	 * @param right
	 *            the value to compare with
	 * @return left.compareTo(right) < 0
	 */
	@Inline("($1.compareTo($2) < 0)")
	public static  boolean operator_lessThan(Comparable left, C right) {
		return left.compareTo(right) < 0;
	}

	/**
	 * The comparison operator greater than.
	 * 
	 * @param left
	 *            a comparable
	 * @param right
	 *            the value to compare with
	 * @return left.compareTo(right) > 0
	 */
	@Inline("($1.compareTo($2) > 0)")
	public static  boolean operator_greaterThan(Comparable left, C right) {
		return left.compareTo(right) > 0;
	}

	/**
	 * The comparison operator less than or equals.
	 * 
	 * @param left
	 *            a comparable
	 * @param right
	 *            the value to compare with
	 * @return left.compareTo(right) <= 0
	 */
	@Inline("($1.compareTo($2) <= 0)")
	public static  boolean operator_lessEqualsThan(Comparable left, C right) {
		return left.compareTo(right) <= 0;
	}

	/**
	 * The comparison operator greater than or equals.
	 * 
	 * @param left
	 *            a comparable
	 * @param right
	 *            the value to compare with
	 * @return left.compareTo(right) >= 0
	 */
	@Inline("($1.compareTo($2) >= 0)")
	public static  boolean operator_greaterEqualsThan(Comparable left, C right) {
		return left.compareTo(right) >= 0;
	}
	
	/**
	 * The spaceship operator <=>.
	 * 
	 * @param left
	 *            a comparable
	 * @param right
	 *            the value to compare with
	 * @return left.compareTo(right)
	 * @since 2.4
	 */
	@Inline("($1.compareTo($2))")
	public static  int operator_spaceship(Comparable left, C right) {
		return left.compareTo(right);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy