|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.sharedutil.Objects
public final class Objects
Utility methods for working with Objects.
| Method Summary | ||
|---|---|---|
static String |
fastToString(Object object)
Returns a string representing the object without calling any methods on the object. |
|
static String |
safeToString(Object object)
Returns a string representing the object, returning a failsafe value if the toString or hashCode methods throw exceptions or if
the method ends up being called recursively. |
|
static
|
uncheckedCast(Object object)
Casts an object to the required type with no unchecked warnings. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String safeToString(Object object)
toString or hashCode methods throw exceptions or if
the method ends up being called recursively.
object - the object or null
public static String fastToString(Object object)
toString might perform to any ManagedReferences that the object
contains, which could lead to exceptions or scaling problems.
Returns "null" if the argument is null, otherwise
returns the concatenation of the fully qualified name of the object's
class, the '#' character, and the identity hash code of the
object as returned by System.identityHashCode, represented in base 16.
object - the object or null
public static <T> T uncheckedCast(Object object)
This method is similar to using the @SuppressWarnings("unchecked") annotation, but is more flexible and often more succinct. It is more flexible because it can be used to convert the type of an object passed as a method argument, while the annotation needs to be applied to a declaration. It is more succinct because it avoids needing to restate the type.
For example, compare:
@SuppressWarnings("unchecked")
Set<Foo> setOfFoo = (Set<Foo>) object;
return foo(setOfFoo);
with:
return foo(uncheckedCast(object));Note that this method cannot be used when the return type is a type variable.
T - the result typeobject - the object to cast
T
|
Project Darkstar, Version 0.9.8 2013-07-29 20:18:36 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||