cakoose.util
Class LangUtil

java.lang.Object
  extended by cakoose.util.LangUtil

public class LangUtil
extends Object


Constructor Summary
LangUtil()
           
 
Method Summary
static
<T> T[]
A(T... elements)
           Returns the given list of values as an array.
static void assertBadType(Object o)
           
static AssertionError badType(Enum<?> e)
           
static AssertionError badType(Object o)
           Returns an AssertionError with a helpful message about what the type of the given object is.
static
<T,R> R
cast(T value)
           
static boolean eq(Object a, Object b)
          Similar to "a.equals(b)" except it works when either value is null.
static RuntimeException todo()
           Returns: new RuntimeException("todo").
static RuntimeException todo(String s)
           Returns: new RuntimeException("todo: " + s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LangUtil

public LangUtil()
Method Detail

badType

public static AssertionError badType(Object o)

Returns an AssertionError with a helpful message about what the type of the given object is. Example use:

 if (e instanceof BinaryOp) {
   BinaryOp b = (BinaryOp) e;
   ...
 } else if (e instanceof Literal) {
   Literal l = (Literal) e;
   ...
 } else {
   throw badType(e);
 }
 


badType

public static AssertionError badType(Enum<?> e)

assertBadType

public static void assertBadType(Object o)

cast

public static <T,R> R cast(T value)

A

public static <T> T[] A(T... elements)

Returns the given list of values as an array.

Example: String[] args = A("java", "-jar", "HelloWorld.jar")


todo

public static RuntimeException todo()

Returns: new RuntimeException("todo").

Example: throw todo().


todo

public static RuntimeException todo(String s)

Returns: new RuntimeException("todo: " + s).

Example: throw todo("error handling").


eq

public static boolean eq(Object a,
                         Object b)
Similar to "a.equals(b)" except it works when either value is null.