Interface DataConverter

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.Object[] arrayFromPayloads​(DataConverter converter, java.util.Optional<io.temporal.api.common.v1.Payloads> content, java.lang.Class<?>[] parameterTypes, java.lang.reflect.Type[] genericParameterTypes)  
      <T> T fromPayload​(io.temporal.api.common.v1.Payload payload, java.lang.Class<T> valueClass, java.lang.reflect.Type valueType)  
      <T> T fromPayloads​(int index, java.util.Optional<io.temporal.api.common.v1.Payloads> content, java.lang.Class<T> valueType, java.lang.reflect.Type valueGenericType)
      Implements conversion of an array of values of different types.
      static DataConverter getDefaultInstance()
      Deprecated.
      <T> java.util.Optional<io.temporal.api.common.v1.Payload> toPayload​(T value)  
      java.util.Optional<io.temporal.api.common.v1.Payloads> toPayloads​(java.lang.Object... values)
      Implements conversion of a list of values.
    • Method Detail

      • toPayload

        <T> java.util.Optional<io.temporal.api.common.v1.Payload> toPayload​(T value)
                                                                     throws DataConverterException
        Parameters:
        value - value to convert
        Returns:
        a Payload which is a protobuf message containing byte-array serialized representation of value. Optional here is for legacy and backward compatibility reasons. This Optional is expected to always be filled.
        Throws:
        DataConverterException - if conversion fails
      • toPayloads

        java.util.Optional<io.temporal.api.common.v1.Payloads> toPayloads​(java.lang.Object... values)
                                                                   throws DataConverterException
        Implements conversion of a list of values.
        Parameters:
        values - Java values to convert to String.
        Returns:
        converted value. Return empty Optional if values are empty.
        Throws:
        DataConverterException - if conversion of the value passed as parameter failed for any reason.
      • fromPayloads

        <T> T fromPayloads​(int index,
                           java.util.Optional<io.temporal.api.common.v1.Payloads> content,
                           java.lang.Class<T> valueType,
                           java.lang.reflect.Type valueGenericType)
                    throws DataConverterException
        Implements conversion of an array of values of different types. Useful for deserializing arguments of function invocations.
        Parameters:
        index - index of the value in the payloads
        content - serialized value to convert to Java objects.
        valueType - type of the value stored in the content
        valueGenericType - generic type of the value stored in the content
        Returns:
        converted Java object
        Throws:
        DataConverterException - if conversion of the data passed as parameter failed for any reason.
      • arrayFromPayloads

        static java.lang.Object[] arrayFromPayloads​(DataConverter converter,
                                                    java.util.Optional<io.temporal.api.common.v1.Payloads> content,
                                                    java.lang.Class<?>[] parameterTypes,
                                                    java.lang.reflect.Type[] genericParameterTypes)
                                             throws DataConverterException
        Throws:
        DataConverterException