Package com.yahoo.reflection
Class Casting
- java.lang.Object
-
- com.yahoo.reflection.Casting
-
public class Casting extends Object
Utility methods for doing casting- Author:
- Tony Vaagenes
-
-
Constructor Summary
Constructors Constructor Description Casting()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Optional<T>
cast(Class<T> targetClass, Object instance)
Returns the casted instance if it is assignment-compatible with targetClass, or empty otherwise.
-
-
-
Method Detail
-
cast
public static <T> Optional<T> cast(Class<T> targetClass, Object instance)
Returns the casted instance if it is assignment-compatible with targetClass, or empty otherwise.- See Also:
Class.isInstance(Object)
-
-