Class ItemParser


  • public class ItemParser
    extends Object
    This class contains a set of methods to help parsing item object between Cognite api representations (json and proto) and typed objects.
    • Constructor Detail

      • ItemParser

        public ItemParser()
    • Method Detail

      • parseItems

        public static List<com.cognite.client.dto.Item> parseItems​(List<String> input)
                                                            throws Exception
        Parses a List of json items (payload from the Cognite api) into an List of Item.
        Parameters:
        input -
        Returns:
        Throws:
        Exception
      • parseItem

        public static com.cognite.client.dto.Item parseItem​(String itemJson)
                                                     throws Exception
        Parses a String (json payload from the Cognite api) into an Item
        Returns:
        Throws:
        Exception
      • toRequestItem

        public static Map<String,​Object> toRequestItem​(com.cognite.client.dto.Item element)
                                                      throws Exception
        Builds a request item object from Item. An item object creates a new asset data object in the Cognite system.
        Parameters:
        element -
        Returns:
        Throws:
        Exception
      • parseLong

        public static Optional<Long> parseLong​(String itemJson,
                                               String fieldName)
        Try parsing the specified Json path as a Long. If the Json node cannot be parsed, an empty Optional will be returned.
        Parameters:
        itemJson - The Json string
        fieldName - The Json path to parse
        Returns:
        The Json path as a Long, or an empty Optional if unable to parse it.
      • parseString

        public static Optional<String> parseString​(String itemJson,
                                                   String fieldName)
        Try parsing the specified Json path as a String. If the Json node cannot be parsed, an empty Optional will be returned.
        Parameters:
        itemJson - The Json string
        fieldName - The Json path to parse
        Returns:
        The Json path as a String, or an empty Optional if unable to parse it.