public class TypeSafe extends Object
| Constructor and Description |
|---|
TypeSafe() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
ensureType(Object object,
Class<T> clazz)
Verifies that the given object can be assigned to a variable with the
given class, returning a type-cast object with the correct type, or
null if the object does not have a matching type. |
static <T> T |
ensureType(Object object,
Class<T> clazz,
T defaultValue)
Verifies that the given object can be assigned to a variable with the
given class, returning a type-cast object with the correct type, or the
default value if the object does not have a matching type.
|
public static <T> T ensureType(Object object, Class<T> clazz)
null if the object does not have a matching type.T - The desired type of the objectobject - The objectclazz - The class of the typenull if the object does not have
a matching typepublic static <T> T ensureType(Object object, Class<T> clazz, T defaultValue)
T - The desired type of the objectobject - The objectclazz - The class of the typedefaultValue - The default value for non-matching objectsCopyright © 2026. All rights reserved.