Class ItemParser

java.lang.Object
com.cognite.client.servicesV1.parser.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 Details

    • ItemParser

      public ItemParser()
  • Method Details

    • parseItems

      public static List<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 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(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.