Class MessageUtil


  • public final class MessageUtil
    extends Object
    The message properties
    • Method Detail

      • getProperty

        public static <T> T getProperty​(org.eclipse.microprofile.reactive.messaging.Message msg,
                                        String name)
        Gets the message property. Check if the property exists.
        Type Parameters:
        T - the property type.
        Parameters:
        msg - the message.
        name - the property name.
        Returns:
        the property value.
      • getStringDateProperty

        public static Date getStringDateProperty​(org.eclipse.microprofile.reactive.messaging.Message<String> msg,
                                                 String name,
                                                 Date defaultDate)
        Gets the message property. Check if the property exists.
        Parameters:
        msg - the message.
        name - the property name.
        defaultDate - the default date.
        Returns:
        the property date.
      • getEnumProperty

        public static <T extends Enum<T>> T getEnumProperty​(org.eclipse.microprofile.reactive.messaging.Message msg,
                                                            String name,
                                                            Class<T> clazz)
        Gets the message enum property. Check if the property exists.
        Type Parameters:
        T - the type parameter
        Parameters:
        msg - the message.
        name - the property name.
        clazz - the property enum type.
        Returns:
        the property value.
      • serializeBody

        public static String serializeBody​(Map<String,​Object> data)
                                    throws IOException
        Serialize the data to string for the TextMessage.
        Parameters:
        data - the data.
        Returns:
        the corresponding string value.
        Throws:
        IOException - if the serialization fails.
      • deserialize

        public static <T> T deserialize​(String data)
        Deserialize the data to string for the database.
        Type Parameters:
        T - type of object to deserialize to
        Parameters:
        data - the data.
        Returns:
        the corresponding string value or null if the data is null.
      • serialize

        public static String serialize​(Object data)
        Serialize the data to string for the database.
        Parameters:
        data - the data.
        Returns:
        the corresponding string value or null if the data is null.
      • deserializeBody

        public static Map<String,​Object> deserializeBody​(org.eclipse.microprofile.reactive.messaging.Message<String> message)
                                                        throws IOException
        Deserialize the message to the map of data.
        Parameters:
        message - the message with the string content.
        Returns:
        the corresponding map of data.
        Throws:
        IOException - if the deserialization of the body fails.
      • stringToDate

        public static Date stringToDate​(String value,
                                        Date defaultValue)
        Converts the string to date.
        Parameters:
        value - the string value.
        defaultValue - the default value.
        Returns:
        the corresponding date value.
      • dateToString

        public static String dateToString​(Date date)
        Date to string string.
        Parameters:
        date - the date
        Returns:
        the string