Class JackMapper

java.lang.Object
overit.geocall.model.JackMapper
All Implemented Interfaces:
Serializable

@Service public class JackMapper extends Object implements Serializable
Mapper used to extract or insert a set of properties inside a bean.
See Also:
  • Constructor Details

  • Method Details

    • parse

      public JsonNode parse(InputStream is) throws IOException
      Parse from an InputStream to create a JsonNode
      Parameters:
      is - The InputStream to parse
      Returns:
      A JsonNode
      Throws:
      IOException - If an I/O error occurs
    • parse

      public <T> T parse(InputStream is, Class<T> c) throws IOException
      Parse from an InputStream and return an object from the class passed as parameter
      Type Parameters:
      T - The type of the object requested
      Parameters:
      is - The InputStream
      c - The requested class
      Returns:
      An object from the requested class
      Throws:
      IOException - If an I/O error occurs
    • parse

      public <T> T parse(InputStream is, String charset, Class<T> c) throws IOException
      Parse from an InputStream and return an object from the class passed as parameter
      Type Parameters:
      T - The type of the object requested
      Parameters:
      is - The InputStream
      charset - The charset for the InputStreamReader
      c - The requested class
      Returns:
      An object from the requested class
      Throws:
      IOException - If an I/O error occurs
    • parse

      public JsonNode parse(Reader r) throws IOException
      Parse from a Reader
      Parameters:
      r - The Reader
      Returns:
      A JsonNode
      Throws:
      IOException - If an I/O error occurs
    • parse

      public <T> T parse(Reader r, Class<T> c) throws IOException
      Parse from a Reader
      Type Parameters:
      T - The type of the object requested
      Parameters:
      r - The Reader
      c - The requested class
      Returns:
      An object from the requested class
      Throws:
      IOException - If an I/O error occurs
    • parse

      public <T> T parse(Reader r, com.fasterxml.jackson.core.type.TypeReference<T> c) throws IOException
      Parse from a Reader
      Type Parameters:
      T - The type of the object requested
      Parameters:
      r - The Reader
      c - The requested generic class
      Returns:
      An object from the requested class
      Throws:
      IOException - If an I/O error occurs
    • parse

      public JsonNode parse(String s) throws IOException
      Parse from a string
      Parameters:
      s - The string to parse
      Returns:
      A JsonNode
      Throws:
      IOException - If an I/O error occurs
    • parse

      public <T> T parse(String s, Class<T> c) throws IOException
      Parse from a string
      Type Parameters:
      T - The type of the object requested
      Parameters:
      s - The string to parse
      c - The requested class
      Returns:
      An object from the requested class
      Throws:
      IOException - If an I/O error occurs
    • parse

      public <T> T parse(String s, com.fasterxml.jackson.core.type.TypeReference<T> c) throws IOException
      Parse from a string
      Type Parameters:
      T - The type reference of the generic object requested
      Parameters:
      s - The string to parse
      c - The requested class
      Returns:
      An object from the requested class
      Throws:
      IOException - If an I/O error occurs
    • parseObject

      public JsonNode parseObject(DynO src)
      Parse an object
      Parameters:
      src - The object to parse
      Returns:
      A JsonNode
    • parseObject

      public JsonNode parseObject(Object src)
      Parse an object
      Parameters:
      src - The dyno to parse
      Returns:
      A JsonNode
    • parseObject

      public <T> T parseObject(DynO src, Class<T> c)
      Parse an object
      Type Parameters:
      T - The type of the DynO requested
      Parameters:
      src - The object to parse
      c - The requested class
      Returns:
      An object from the requested class
    • parseObject

      public <T> T parseObject(Object src, Class<T> c)
      Parse an object
      Type Parameters:
      T - The type of the object requested
      Parameters:
      src - The object to parse
      c - The requested class
      Returns:
      An object from the requested class
    • update

      public <T> T update(Object src, T to) throws JsonMappingException
      Update an object
      Type Parameters:
      T - The type of the object
      Parameters:
      src - Object to conceptually serialize and merge into value to update
      to - Object to update
      Returns:
      Either the second argument (`to`), if it is mutable; or a result of creating new instance that is result of "merging" values (for example, "updating" a Java array will create a new array)
      Throws:
      JsonMappingException - If there are structural incompatibilities that prevent update
    • format

      public void format(Object o, OutputStream os) throws IOException
      Format an object
      Parameters:
      o - The object
      os - The OutputStream
      Throws:
      IOException - If an I/O error occurs
    • format

      public void format(Object o, String charset, OutputStream os) throws IOException
      Format an object
      Parameters:
      o - The object
      charset - The charset for the OutputStreamWriter
      os - The OutputStream
      Throws:
      IOException - If an I/O error occurs
    • format

      public void format(Object o, Writer w) throws IOException
      Format an object
      Parameters:
      o - The object
      w - The Writer
      Throws:
      IOException - If an I/O error occurs
    • format

      public String format(Object o) throws IOException
      Format an object
      Parameters:
      o - The object
      Returns:
      The string representing the formatted object
      Throws:
      IOException - If an I/O error occurs
    • extract

      public Map<String,Object> extract(Object o, boolean nullValues, boolean any)
      Collects and returns all the properties of a bean without conversions, but respecting jackson annotations
      Parameters:
      o - The object to be introspected
      nullValues - true for keeping null values inside the map, false otherwise
      any - true for extracting also the additional properties with the Jackson any-getter, false otherwise If any conflict exists between the concrete-properties and the any-properties, the concrete-property wins
      Returns:
      The map containing all the properties. The key of the pair is the name the value is the property object
    • insert

      public void insert(Map<String,Object> m, Object o, boolean nullValues, boolean any)
      Insert a set of properties inside a bean without conversions, but respecting jackson annotations
      Parameters:
      m - The collection of key-value properties to be inserted
      o - The object receiving the insertions
      nullValues - true for inserting null values inside the object, false otherwise
      any - true for inserting absent bean properties to the any-setter if presents , false otherwise If any conflict exists between the concrete-properties and the any-properties, the value will be inserted in the concrete-property
    • fields

      public Set<String> fields(Class<?> clz, boolean out, boolean in)
      Collects the properties of a bean-class respecting jackson annotations
      Parameters:
      clz - The object to be introspected
      out - true to request all the properties used in formatting, false otherwise
      in - true to request all the properties used in parsing, false otherwise
      Returns:
      A set of Strings with all the requested properties
    • validateObject

      protected void validateObject(Object obj)