Class ValueWrapper

    • Method Detail

      • create

        public static ValueWrapper create​(Object value)
        Factory for creating a new ValueWrapper for the supplied value.

        If the supplied value is null, this method will return a cached ValueWrapper suitable for all null values. If the supplied value is already an instance of ValueWrapper, it will be returned as is.

        Parameters:
        value - the value to wrap; may be null
        Returns:
        a wrapper for the supplied value; never null
      • create

        public static ValueWrapper create​(Object value,
                                          String stringRepresentation)
        Factory for creating a new ValueWrapper for the supplied value using the supplied custom stringRepresentation.

        You should use this method when you don't want to rely on the result of the value's toString() method.

        If the supplied value is null, this method will return a cached ValueWrapper suitable for all null values. If the supplied value is already an instance of ValueWrapper, it will be returned as is if the stringRepresentation match, otherwise the original value will be unwrapped and a new ValueWrapper with the new stringRepresentation will be created.

        Parameters:
        value - the value to wrap; may be null
        stringRepresentation - a custom rendering of the value; will fallback to the default behavior if null
        Returns:
        a wrapper for the supplied value; never null
        Since:
        1.2
      • getType

        public Class<?> getType()
        Returns the value's runtime type or null if the value is null.
      • getEphemeralValue

        public Object getEphemeralValue()
        Returns the original value supplied to create().

        If this ValueWrapper was created by deserialization this method returns null.

        Since:
        1.2
        See Also:
        getValue()
      • toString

        public String toString()
        Returns the value's string representation along with its type and identity hash code.
        Overrides:
        toString in class Object