Class SerializeHelper


  • public class SerializeHelper
    extends Object
    The SerializeHelper provides a set of tools, to translate the server“s responses and data transfer objects, which may be provided using one of the defined DataFormats.
    • Method Detail

      • fromXML

        @NotNull
        public static <T> T fromXML​(@Nullable
                                    @Nullable org.apache.hc.core5.http.HttpEntity httpEntity,
                                    @NotNull
                                    @NotNull Class<T> type)
                             throws ResultException
        Deserialize the data transfer object to the given type from the given DataFormat.XML HttpEntity.
        Type Parameters:
        T - The expected type of the deserialized data transfer object.
        Parameters:
        httpEntity - The deserializable DataFormat.XML HttpEntity
        type - The expected type of the deserialized data transfer object.
        Returns:
        The deserialized DataFormat.XML data transfer object.
        Throws:
        ResultException - Shall be thrown upon a deserialization failure.
      • fromXML

        @NotNull
        public static <T> T fromXML​(@Nullable
                                    @Nullable StreamSource streamSource,
                                    @NotNull
                                    @NotNull Class<T> type)
                             throws ResultException
        Deserialize the data transfer object to the given type from the given DataFormat.XML StreamSource.
        Type Parameters:
        T - The expected type of the deserialized data transfer object.
        Parameters:
        streamSource - The deserializable DataFormat.XML StreamSource
        type - The expected type of the deserialized data transfer object.
        Returns:
        The deserialized DataFormat.XML data transfer object.
        Throws:
        ResultException - Shall be thrown upon a deserialization failure.
      • fromJSON

        @NotNull
        public static <T> T fromJSON​(@Nullable
                                     @Nullable org.apache.hc.core5.http.HttpEntity httpEntity,
                                     @NotNull
                                     @NotNull Class<T> type)
                              throws ResultException
        Deserialize the data transfer object to the given type from the given DataFormat.JSON HttpEntity.
        Type Parameters:
        T - The expected type of the deserialized data transfer object.
        Parameters:
        httpEntity - The deserializable DataFormat.JSON HttpEntity
        type - The expected type of the deserialized data transfer object.
        Returns:
        The deserialized DataFormat.JSON data transfer object.
        Throws:
        ResultException - Shall be thrown upon a deserialization failure.
      • fromJSON

        @NotNull
        public static <T> T fromJSON​(@Nullable
                                     @Nullable StreamSource streamSource,
                                     @NotNull
                                     @NotNull Class<T> type)
                              throws ResultException
        Deserialize the data transfer object to the given type from the given DataFormat.JSON StreamSource.
        Type Parameters:
        T - The expected type of the deserialized data transfer object.
        Parameters:
        streamSource - The deserializable DataFormat.JSON StreamSource
        type - The expected type of the deserialized data transfer object.
        Returns:
        The deserialized DataFormat.JSON data transfer object.
        Throws:
        ResultException - Shall be thrown upon a deserialization failure.
      • toXML

        @NotNull
        public static @NotNull String toXML​(@Nullable
                                            @Nullable Object object,
                                            @NotNull
                                            @NotNull Class<?> type)
                                     throws ResultException
        Serialize a data transfer object to DataFormat.XML.
        Parameters:
        object - The data transfer object to serialize.
        type - The annotated type of the data transfer object.
        Returns:
        The resulting DataFormat.XML String.
        Throws:
        ResultException - Shall be thrown upon a serialization failure.