Package net.imglib2.util
Class Cast
- java.lang.Object
-
- net.imglib2.util.Cast
-
public final class Cast extends java.lang.ObjectUtility class for type casts.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateCast()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tunchecked(java.lang.Object value)Performs an unchecked cast.
-
-
-
Method Detail
-
unchecked
public static <T> T unchecked(java.lang.Object value)
Performs an unchecked cast.For example this code snipped:
Can be rewritten as:@SuppressWarnings("unchecked")Img<T> image = (Img<T>) ArrayImgs.ints(100, 100);
It's possible to explicitly specify the return type:Img<T> image = Casts.unchecked( ArrayImgs.ints(100, 100) );Img<T> image = Casts.<Img<T>>unchecked( ArrayImgs.ints(100, 100) );- Throws:
java.lang.ClassCastException- during runtime, if the cast is not possible.
-
-