|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.ocl.examples.common.utils.ClassUtils
public class ClassUtils
| Constructor Summary | |
|---|---|
ClassUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
asClassOrNull(java.lang.Object object,
java.lang.Class<T> requiredClass)
Return object cast to requiredClass. |
|
static
|
asClassUnchecked(java.lang.Object object)
Return object cast to T without a check. |
|
static
|
asClassUnchecked(java.lang.Object object,
T requiredClassObject)
Return object cast to T without a check. |
|
static boolean |
equals(java.lang.Object left,
java.lang.Object right)
Return true if left and right are equal, avoiding an NPE by first using left==right before attempting left.equals(right). |
|
static
|
getClass(T object)
Return the fully typed class of an object. |
|
static
|
isInstanceOf(java.lang.Object anObject,
java.lang.Class<T> aClass)
Return anObject cast to aClass if type-safe or null otherwise. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ClassUtils()
| Method Detail |
|---|
public static <T> T asClassOrNull(java.lang.Object object,
java.lang.Class<T> requiredClass)
object - to cast.requiredClass - to cast to.
public static <T> T asClassUnchecked(java.lang.Object object,
T requiredClassObject)
This enables type-checking to be suppressed on a single expression term avoiding the need for suppressing unchecked warnings throughout the rest of an invoking method.
Use as: asClassUnchecked(object, (ArbitrarilyComplicatedType)null)
T - required typeobject - to castrequiredClassObject - dummy argument: use null
public static <T> T asClassUnchecked(java.lang.Object object)
This enables type-checking to suppressed on a single expression term avoiding the need for suppressing unchecked warnings throughout the rest of an invoking method.
Use as: ArbitrarilyComplicatedType castObject = asClassUnchecked(object);
T - required typeobject - to cast
public static boolean equals(java.lang.Object left,
java.lang.Object right)
left - right -
public static <T> java.lang.Class<T> getClass(T object)
T - typeobject - the object
public static <T> T isInstanceOf(java.lang.Object anObject,
java.lang.Class<T> aClass)
anObject - for which cast requiredaClass - the type to which cast required
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||