org.eclipse.xtext.xbase.lib
Class IntegerExtensions

java.lang.Object
  extended by org.eclipse.xtext.xbase.lib.IntegerExtensions

public class IntegerExtensions
extends java.lang.Object

This is an extension library for integral numbers, e.g. int or Integer.

Author:
Sven Efftinge - Initial contribution and API

Nested Class Summary
protected static class IntegerExtensions.IntIterator
          Implementation of an iterator for integers.
 
Constructor Summary
IntegerExtensions()
           
 
Method Summary
static int operator_divide(java.lang.Integer a, java.lang.Number b)
          The binary divide operator.
static int operator_minus(java.lang.Integer a)
          The unary minus operator.
static int operator_minus(java.lang.Integer a, java.lang.Number b)
          The binary minus operator.
static int operator_modulo(java.lang.Integer a, java.lang.Number b)
          The binary modulo operator.
static int operator_multiply(java.lang.Integer a, java.lang.Number b)
          The binary times operator.
static int operator_plus(java.lang.Integer a, java.lang.Number b)
          The binary plus operator.
static int operator_power(java.lang.Integer a, java.lang.Number b)
          The power operator.
static java.lang.Iterable<java.lang.Integer> operator_upTo(java.lang.Integer a, java.lang.Number b)
          The upTo operator yields an iterable of integral numbers from a up to b if b is larger than a or otherwise from a down to b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerExtensions

public IntegerExtensions()
Method Detail

operator_minus

public static int operator_minus(java.lang.Integer a)
The unary minus operator. This is the equivalent to the unary java - operator.

Parameters:
a - an integer. May not be null.
Returns:
-a
Throws:
java.lang.NullPointerException - if a is null.

operator_plus

public static int operator_plus(java.lang.Integer a,
                                java.lang.Number b)
The binary plus operator. This is the equivalent to the java + operator.

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
a+b
Throws:
java.lang.NullPointerException - if a or b is null.

operator_minus

public static int operator_minus(java.lang.Integer a,
                                 java.lang.Number b)
The binary minus operator. This is the equivalent to the java - operator.

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
a-b
Throws:
java.lang.NullPointerException - if a or b is null.

operator_multiply

public static int operator_multiply(java.lang.Integer a,
                                    java.lang.Number b)
The binary times operator. This is the equivalent to the java * operator.

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
a*b
Throws:
java.lang.NullPointerException - if a or b is null.

operator_divide

public static int operator_divide(java.lang.Integer a,
                                  java.lang.Number b)
The binary divide operator. This is the equivalent to the java / operator. That is, the result will be the integral result of the division, e.g. operator_divide(1, 2) yields 0 .

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
a/b
Throws:
java.lang.NullPointerException - if a or b is null.

operator_modulo

public static int operator_modulo(java.lang.Integer a,
                                  java.lang.Number b)
The binary modulo operator. This is the equivalent to the java % operator.

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
a%b
Throws:
java.lang.NullPointerException - if a or b is null.

operator_power

public static int operator_power(java.lang.Integer a,
                                 java.lang.Number b)
The power operator.

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
a ** b
Throws:
java.lang.NullPointerException - if a or b is null.

operator_upTo

public static java.lang.Iterable<java.lang.Integer> operator_upTo(java.lang.Integer a,
                                                                  java.lang.Number b)
The upTo operator yields an iterable of integral numbers from a up to b if b is larger than a or otherwise from a down to b.

Parameters:
a - an integer. May not be null.
b - a number. May not be null.
Returns:
an iterable of integral numbers. Never null.
Throws:
java.lang.NullPointerException - if a or b is null.