Package org.opentest4j
Class ValueWrapper
- java.lang.Object
-
- org.opentest4j.ValueWrapper
-
- All Implemented Interfaces:
java.io.Serializable
public final class ValueWrapper extends java.lang.Object implements java.io.Serializable
Serializable representation of a value that was used in an assertion.This class only stores the value if it implements
Serializable
. In any case, it stores its runtime type, identity hash code and string representation, i.e. the result of invokingObject.toString()
.The
toString()
method returns the string representation of the value along with its type and identity hash code.- Since:
- 1.0
- Author:
- Marc Philipp, Sam Brannen
- See Also:
System.identityHashCode(java.lang.Object)
, Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ValueWrapper
create(java.lang.Object value)
Factory for creating a newValueWrapper
for the suppliedvalue
.int
getIdentityHashCode()
Returns the value's identity hash code, i.e.java.lang.String
getStringRepresentation()
Returns the value's string representation, i.e.java.lang.Class<?>
getType()
Returns the value's runtime type in case it wasn'tnull
; otherwise,null
.java.io.Serializable
getValue()
Returns the value as passed to the constructor in case it implementedSerializable
; otherwise,null
.java.lang.String
toString()
Returns the value's string representation along with its type and identity hash code.
-
-
-
Method Detail
-
create
public static ValueWrapper create(java.lang.Object value)
Factory for creating a newValueWrapper
for the suppliedvalue
.If the supplied
value
isnull
, this method will return a cachedValueWrapper
suitable for all null values.- Parameters:
value
- the value to wrap- Returns:
- a wrapper for the supplied value
-
getValue
public java.io.Serializable getValue()
Returns the value as passed to the constructor in case it implementedSerializable
; otherwise,null
.
-
getType
public java.lang.Class<?> getType()
Returns the value's runtime type in case it wasn'tnull
; otherwise,null
.
-
getStringRepresentation
public java.lang.String getStringRepresentation()
Returns the value's string representation, i.e. the result of invokingObject.toString()
at the time this object's constructor was called. Returns"null"
if the value wasnull
.
-
getIdentityHashCode
public int getIdentityHashCode()
Returns the value's identity hash code, i.e. the result of invokingSystem.identityHashCode(java.lang.Object)
at the time this object's constructor was called. Returns0
if the value wasnull
.
-
toString
public java.lang.String toString()
Returns the value's string representation along with its type and identity hash code.- Overrides:
toString
in classjava.lang.Object
-
-