Class MapperUtil

java.lang.Object
com.skava.payment.util.MapperUtil

public class MapperUtil extends Object
MapperUtil
Since:
17/12/2018
Author:
Infosys Equinox
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final com.fasterxml.jackson.databind.ObjectMapper
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> com.skava.core.event.Message<T>
    castFromTypeRef(byte[] bs)
    Method to convert the given bytes into Message T using typeReference.
    static <T> T
    castTypeFromBytes(byte[] content, Class<T> requiredType)
    Method to convert the given JsonNode content to required class.
    static <T> T
    castTypeFromObject(Object content, Class<T> requiredType)
    Method to convert the given JsonNode content to required class.
    static <T> T
    castTypeFromString(String content, Class<T> requiredType)
    Method to convert the given JsonNode content to required class
    static com.fasterxml.jackson.databind.JsonNode
    Method to get the jsonNode for given object.
    static <T> com.fasterxml.jackson.databind.ObjectReader
    getReader(Class<T> requiredType)
    Method to get the reader object for the given type.
    static String
    getWriter(Object content)
    Method to get the writer for the given content

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EXCEPTION_CONST

      public static final String EXCEPTION_CONST
      See Also:
    • objectMapper

      public static final com.fasterxml.jackson.databind.ObjectMapper objectMapper
  • Constructor Details

    • MapperUtil

      protected MapperUtil()
  • Method Details

    • getReader

      public static <T> com.fasterxml.jackson.databind.ObjectReader getReader(Class<T> requiredType)
      Method to get the reader object for the given type.
      Type Parameters:
      T - This describes the generic type parameter.
      Parameters:
      requiredType - It has the required class.
      Returns:
      A ObjectReader object.
    • getWriter

      public static String getWriter(Object content)
      Method to get the writer for the given content
      Parameters:
      content - A Object. It consists of details which needs to be converted to String.
      Returns:
      A String for the given content.
    • castFromTypeRef

      public static <T> com.skava.core.event.Message<T> castFromTypeRef(byte[] bs)
      Method to convert the given bytes into Message T using typeReference.
      Type Parameters:
      T - This describes the generic type parameter.
      Parameters:
      bs - It consists of the content which is converted to bytes.
      Returns:
      Returns Message T where T is a generic class to which the bytes are converted to.
    • castTypeToJsonNode

      public static com.fasterxml.jackson.databind.JsonNode castTypeToJsonNode(Object content)
      Method to get the jsonNode for given object. Replicate for valueToTree
      Parameters:
      content - A Object. It consists of details which needs to be converted to JsonNode.
      Returns:
      Returns a JsonNode for the given content.
    • castTypeFromObject

      public static <T> T castTypeFromObject(Object content, Class<T> requiredType)
      Method to convert the given JsonNode content to required class. Replicate for TreeToValue.
      Type Parameters:
      T - This describes the generic type parameter.
      Parameters:
      content - A Object. It consists of details which needs to be converted to given type T.
      requiredType - It has the required class.
      Returns:
      Returns T to which the content needs to be converted.
    • castTypeFromBytes

      public static <T> T castTypeFromBytes(byte[] content, Class<T> requiredType)
      Method to convert the given JsonNode content to required class.
      Type Parameters:
      T - This describes the generic type parameter.
      Parameters:
      content - It consists of the content which is converted to bytes. which needs to be converted to given type T.
      requiredType - It has the required class.
      Returns:
      Returns T to which the content needs to be converted.
    • castTypeFromString

      public static <T> T castTypeFromString(String content, Class<T> requiredType)
      Method to convert the given JsonNode content to required class
      Type Parameters:
      T - - type reference
      Parameters:
      content - - string data
      requiredType - Contains the return type
      Returns:
      class