T
- The type of the object instance to track.public class TypedObject<T> extends java.lang.Object implements ReifiedType<TypedObject<T>>
Modifier and Type | Method and Description |
---|---|
<U> TypedObject<U> |
assign(TypeToken<U> type)
Cast a typed object into a differently typed object, succeeding only if the
types are assignment compatible.
|
<U> TypedObject<U> |
cast(TypeToken<U> type)
Cast a typed object into a differently typed object.
|
static <T> TypedObject<T> |
castUnsafe(java.lang.Object object,
TypeToken<T> type)
Cast an untyped object into a typed object without consideration for generic
type safety.
|
<U> TypedObject<U> |
castUnsafe(TypeToken<U> type)
Cast a typed object into a differently typed object without consideration for
generic type safety.
|
boolean |
equals(java.lang.Object obj) |
T |
getObject() |
TypeToken<TypedObject<T>> |
getThisTypeToken() |
java.lang.reflect.Type |
getType() |
TypeToken<T> |
getTypeToken() |
int |
hashCode() |
java.lang.String |
toString() |
<U> java.util.Optional<TypedObject<U>> |
tryAssign(TypeToken<U> type)
Cast a typed object into a differently typed object, succeeding only if the
types are assignment compatible.
|
<U> java.util.Optional<TypedObject<U>> |
tryCast(TypeToken<U> type)
Cast a typed object into a differently typed object.
|
static <T> TypedObject<T> |
typedObject(java.lang.Class<T> type,
T object)
Convenience method to return a
TypedObject wrapper around an object
instance of this type. |
static <T> TypedObject<T> |
typedObject(TypeToken<T> type,
T object)
Convenience method to return a
TypedObject wrapper around an object
instance of this type. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asTypedObject, getThisType
public static <T> TypedObject<T> typedObject(TypeToken<T> type, T object)
TypedObject
wrapper around an object
instance of this type.object
- The object to wrap with a typed containerpublic static <T> TypedObject<T> typedObject(java.lang.Class<T> type, T object)
TypedObject
wrapper around an object
instance of this type.object
- The object to wrap with a typed containerpublic static <T> TypedObject<T> castUnsafe(java.lang.Object object, TypeToken<T> type)
T
- The target type of the casttype
- A type token over the type of the castobject
- The object to castpublic <U> TypedObject<U> castUnsafe(TypeToken<U> type)
U
- The target type of the casttype
- A type token over the type of the castpublic <U> java.util.Optional<TypedObject<U>> tryCast(TypeToken<U> type)
U
- The target type of the casttype
- A type token over the type of the castpublic <U> TypedObject<U> cast(TypeToken<U> type)
U
- The target type of the casttype
- A type token over the type of the castpublic <U> java.util.Optional<TypedObject<U>> tryAssign(TypeToken<U> type)
U
- The target type of the casttype
- A type token over the type of the castpublic <U> TypedObject<U> assign(TypeToken<U> type)
U
- The target type of the casttype
- A type token over the type of the castpublic java.lang.reflect.Type getType()
public T getObject()
public java.lang.String toString()
toString
in class java.lang.Object
public TypeToken<TypedObject<T>> getThisTypeToken()
getThisTypeToken
in interface ReifiedType<TypedObject<T>>
TypeToken
over the value of ReifiedType.getThisType()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object