Interface ICObject

All Superinterfaces:
Cloneable, Serializable
All Known Subinterfaces:
ILabels, IView
All Known Implementing Classes:
AnyFolder, AnyGroup, AnyRoom, AnyTask, AnyTaskAction, AnyTaskAttachment, AnyUser, AnyUsersReporting, ApiColumn, ApiConfigModule, ApiDuplicateDocument, ApiDuplicatesResult, ApiExportConfigOptions, ApiFilteredSearchRequest, ApiFullTextSearchRequest, ApiImportConfigOptions, ApiLabel, ApiMember, ApiMetadataDocument, ApiOcrFileFeedback, ApiOcrResult, ApiSendTaskResult, ApiSignUrlResult, CObject, Labels, Predicate, Range, View

public interface ICObject extends Serializable, Cloneable
The Interface ICObject to manage internal JSON content.
  • Field Details

  • Method Details

    • isEmpty

      boolean isEmpty()
      Checks if the field is object empty.
      Returns:
      true, if empty
    • isBoolean

      boolean isBoolean(String fieldOrPath)
      Checks if a field is a boolean.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is boolean
    • isDate

      boolean isDate(String fieldOrPath)
      Checks if the field is a date.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is date
    • isString

      boolean isString(String fieldOrPath)
      Checks if the field is a string.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is string
    • isInt

      boolean isInt(String fieldOrPath)
      Checks if the field is an integer.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is int
    • isDouble

      boolean isDouble(String fieldOrPath)
      Checks if the field is a double.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is double
    • containsField

      boolean containsField(String fieldOrPath)
      Check if object contains a field.
      Parameters:
      fieldOrPath - the field name or field path to search
      Returns:
      true, if the field exists
    • getBoolean

      boolean getBoolean(String fieldOrPath, boolean def)
      Gets the boolean value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the boolean value
    • getBoolean

      boolean getBoolean(String fieldOrPath)
      Gets the boolean value.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the boolean value or false if field does not exist
    • get

      Object get(String fieldOrPath, Object def)
      Gets the object value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the object value
    • set

      void set(String fieldOrPath, ICObject value)
      Sets the field typed value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the typed value
    • set

      void set(String fieldOrPath, Object value)
      Sets the field typed value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the typed value
    • set

      void set(String fieldOrPath, boolean value)
      Sets the field typed value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the typed value
    • set

      void set(String fieldOrPath, Map<String,Object> values)
      Sets the field value with a new nested object created from a Map. Each key/object from the map is converted to a field/field value in the new object.
      Parameters:
      fieldOrPath - the field name or field path
      values - the values converted to a nested object
    • setNull

      void setNull(String fieldOrPath)
      Sets the null value.
      Parameters:
      fieldOrPath - the field name or field path
    • getInt

      int getInt(String fieldOrPath, int def)
      Gets the integer value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the integer value
    • getInt

      int getInt(String fieldOrPath)
      Gets the integer value.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the integer value or 0
    • getLong

      long getLong(String fieldOrPath, long def)
      Gets the long value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the long value
    • getLong

      long getLong(String field)
      Gets the long value or 0 if field does not exist.
      Parameters:
      field - the field
      Returns:
      the long value or 0
    • set

      void set(String fieldOrPath, long value)
      Sets the long value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
    • getDouble

      double getDouble(String fieldOrPath, double def)
      Gets the double value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the double value
    • getDouble

      double getDouble(String fieldOrPath)
      Gets the double value or 0 if field does not exist.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the double value or 0
    • set

      void set(String fieldOrPath, double value)
      Sets the double value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
    • getString

      String getString(String fieldOrPath, String def)
      Gets the string value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the string value
    • getString

      String getString(String fieldOrPath)
      Gets the string value or NULL if field does not exist.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the string or NULL
    • set

      void set(String fieldOrPath, String value)
      Sets the string value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
    • getDate

      Date getDate(String fieldOrPath, Date def)
      Gets the date value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the date value
    • getDate

      Date getDate(String field)
      Gets the date value or NULL if field does not exsit.
      Parameters:
      field - the field
      Returns:
      the date value or NULL
    • set

      void set(String fieldOrPath, Date value)
      Sets the date value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
    • getLocalDateTime

      LocalDateTime getLocalDateTime(String fieldOrPath, LocalDateTime def)
      Gets the local date time value.
      Parameters:
      fieldOrPath - the field name or field path
      def - the default value if field does not exist
      Returns:
      the local date time
    • getLocalDateTime

      LocalDateTime getLocalDateTime(String fieldOrPath)
      Gets the local date time value or NULL if field does not exist.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the local date time value or NULL
    • set

      void set(String fieldOrPath, LocalDateTime value)
      Sets the local date time value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
    • getListString

      List<String> getListString(String fieldOrPath)
      Gets the list of string.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the list string or empty list string if field does not exist
    • getListNestedObject

      List<ICObject> getListNestedObject(String fieldOrPath)
      Gets the list of nested objects.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the list nested objects or empty list if field does not exist
    • getListNestedObject

      <T> List<T> getListNestedObject(String fieldOrPath, Class<T> clazz)
      Returns a list of values instantiated as the Class passed as parameters.

      Be sure that the class you are passing as parameter (or its implementation) has a constructor with the JsonNode parameters or it will not work.

      Type Parameters:
      T - the generic type implemeting JsonNode or CObject
      Parameters:
      fieldOrPath - : name of the field used to retrieve the list.
      clazz - : class used to instantiate the object returned in the list.
      Returns:
      a List of instantiated object
    • getListNestedObject

      <T> List<T> getListNestedObject(String fieldOrPath, Class<T> clazz, Class<? extends T> implClazz)
      Returns a list of values instantiated as the Class passed as parameters and implementation class passed as argument.

      Be sure that the class you are passing as parameter (or its implementation) has a constructor with the JsonNode parameters or it will not work.

      Type Parameters:
      T - the generic type implemeting JsonNode or CObject *
      Parameters:
      fieldOrPath - name of the field used to retrieve the list.
      clazz - class used to instantiate the object returned in the list.
      implClazz - class used to instaciante the object if Clazz corresponds to an interface
      Returns:
      a List of instantiated object
    • getListNestedObjectByAttribute

      List<ICObject> getListNestedObjectByAttribute(String fieldOrPath, String nestedFieldName, String fieldValue)
      Gets the list nested object filtered by nested object field value.
      Parameters:
      fieldOrPath - name of the field used to retrieve the list
      nestedFieldName - the field name to test on nested objects
      fieldValue - the field value to test (object.equals())
      Returns:
      the filtered list of nested object matching field value
    • getListNestedObjectByAttribute

      <T> List<T> getListNestedObjectByAttribute(String fieldOrPath, String nestedFieldName, String fieldValue, Class<T> clazz)
      Gets the list nested object instantiated with a class and filtered by nested object field value.
      Type Parameters:
      T - the generic type implemeting JsonNode or CObject
      Parameters:
      fieldOrPath - name of the field used to retrieve the list
      nestedFieldName - the field name to test on nested objects
      fieldValue - the field value to test (object.equals())
      clazz - class used to instantiate the object returned in the list.
      Returns:
      the filtered list of nested object matching field value
    • isList

      boolean isList(String fieldOrPath)
      Checks if the field is a list.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is a list
    • isNestedObject

      boolean isNestedObject(String fieldOrPath)
      Checks if the field is a nested object.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is a nested object
    • setList

      void setList(String fieldOrPath, Collection<?> values)
      Sets the list values.
      Parameters:
      fieldOrPath - the field name or field path
      values - the values
    • clearList

      void clearList(String fieldOrPath)
      Clear list values.
      Parameters:
      fieldOrPath - the field name or field path
    • remove

      void remove(String fieldOrPath)
      Removes the field.
      Parameters:
      fieldOrPath - the field name or field path
    • toMap

      Map<String,Object> toMap()
      Convert object to a map.
      Returns:
      the map
    • toString

      String toString()
      Convert object to a string.
      Overrides:
      toString in class Object
      Returns:
      the string
    • toJson

      String toJson()
      Convert object to a JSON string formated.
      Returns:
      the string
    • getFieldNames

      Iterator<String> getFieldNames()
      Gets the direct field names as iterator.
      Returns:
      the field names iterator
    • getFieldNamesList

      List<String> getFieldNamesList()
      Gets the field names list.
      Returns:
      the field names list
    • getNestedObjectNamesList

      List<String> getNestedObjectNamesList()
      Gets the nested object field names list.
      Returns:
      the list of field names containing a nested object
    • getFieldNamesFlattenList

      List<String> getFieldNamesFlattenList()
      Gets the field names flatten list of all fields recursively. Indirect filed names use the dot path pattern (a.b.c)
      Returns:
      the field names flatten list
    • toFlattenMapValues

      Map<String,Object> toFlattenMapValues()
      Get map of flatten names with values. Map only include final values and list values but intermediate nested object.

      ex : {a : "a", b : { c : "c", d : ["d1",d2",d3"]} return a map {a = "a", b.c = "c", b.d= ["d1",d2",d3"]}

      Separator used for field names is the dot.

      Returns:
      Map of values
    • getNestedObject

      ICObject getNestedObject(String fieldOrPath)
      Gets the nested object.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the nested object
    • getNestedObject

      <T extends ICObject> T getNestedObject(String fieldOrPath, Class<T> clazz, Class<? extends T> implClazz)
      Gets the nested object instantiated with a provided class.
      Type Parameters:
      T - the generic type
      Parameters:
      fieldOrPath - the field name or field path
      clazz - the class interface
      implClazz - the implementation class
      Returns:
      the nested object
    • contains

      boolean contains(String fieldOrPath, Object value)
      Checks if object contains a field with specified value.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
      Returns:
      true, if successful
    • getNestedObject

      <T extends ICObject> T getNestedObject(String fieldOrPath, Class<T> clazz)
      Gets the nested object instantiated with a provided class.
      Type Parameters:
      T - the generic type
      Parameters:
      fieldOrPath - the field name or field path
      clazz - the implementation or interface class
      Returns:
      the nested object
    • load

      ICObject load(InputStream input) throws IOException
      Load object from input JSON stream.
      Parameters:
      input - the input stream. Must contain JSON string.
      Returns:
      the object loaded
      Throws:
      IOException - I/O exception has occurred or stream cannot be parsed.
    • load

      ICObject load(ICObject obj)
      Load object from another instance of ICObject.
      Parameters:
      obj - the object to copy
      Returns:
      the object loaded
    • merge

      void merge(ICObject jsonPlugin)
      Merge another instance of ICObject into this object. The merge adds missing fields and overwrite existings ones.
      Parameters:
      jsonPlugin - the json plugin
    • mergeDeep

      ICObject mergeDeep(ICObject obj, boolean keepExisting, boolean skipEmpty)
      Merge deeply another instance of ICObject into this object.Compared to merge(), this method merges every values and is not limited to tree nodes. Use it if you want to merge everything including leaves
      Parameters:
      obj - Object instance of ICObject to merge
      keepExisting - : if set to true, any value existing in the source object won't be overriden by the json provided in parameter
      skipEmpty - : if set to true, any incoming value with empty string ("") will be considered as null and will not override the source value
      Returns:
      the object merged
    • isFieldEmpty

      boolean isFieldEmpty(String fieldOrPath)
      Checks if the field is empty.
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      true, if the field is empty string or empty list.
    • equals

      boolean equals(Object object)
      Checks if current object is equals to another.
      Overrides:
      equals in class Object
      Parameters:
      object - the object
      Returns:
      true, if compared object is instance of ICObject, compared object have exactly same fields names and all fields values are equals.
    • removeFromList

      void removeFromList(String fieldOrPath, Collection<?> values)
      Removes values from list values of a field.
      Parameters:
      fieldOrPath - the field name or field path
      values - the values to remove
    • replaceIntoList

      void replaceIntoList(String fieldOrPath, Object value, int i)
      Replaces a value into a field with a list of values using index.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value to set
      i - the index to replace into the list of values
    • removeValueFromList

      void removeValueFromList(String fieldOrPath, Object toBeRemovedValue)
      Removes the value from list values of a field.
      Parameters:
      fieldOrPath - the field name or field path
      toBeRemovedValue - the value to be removed
    • addIntoList

      void addIntoList(String fieldOrPath, Collection<?> values)
      Append values into a field with a list of values.
      Parameters:
      fieldOrPath - the field name or field path
      values - the values
    • addValueIntoList

      void addValueIntoList(String fieldOrPath, Object value)
      Append value into a field with a list of values.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
    • insertIntoList

      void insertIntoList(String fieldOrPath, Object value, int i)
      Insert a value into a field with a list of values at the specified index.
      Parameters:
      fieldOrPath - the field name or field path
      value - the value
      i - the index
    • getListSize

      int getListSize(String fieldOrPath)
      Gets the list size of a field with a list of values..
      Parameters:
      fieldOrPath - the field name or field path
      Returns:
      the list size or 0 if field is not a list
    • clone

      ICObject clone()
      Clone the object.
      Returns:
      the object cloned
    • clone

      <T extends ICObject> T clone(Class<T> clazz)
      Clone the object as new class.
      Type Parameters:
      T - the generic type
      Parameters:
      clazz - the class to implement the clone
      Returns:
      the cloned object instance of provided class
    • clone

      <T extends ICObject> T clone(Class<T> clazz, Class<? extends T> implClazz)
      Clone the object as new class.
      Type Parameters:
      T - the generic type
      Parameters:
      clazz - the interface to implement the clone
      implClazz - the class to implement the clone
      Returns:
      the cloned object instance of provided class
    • toString

      String toString(boolean autoIndent)
      Convert to string with auto indentation.
      Parameters:
      autoIndent - Set to true to activate the auto indentation
      Returns:
      the string result
    • textValue

      String textValue()
      Convert to text value.
      Returns:
      the string
    • getOutputStream

      ByteArrayOutputStream getOutputStream(boolean prettyPrint)
      Gets the object as output stream.
      Parameters:
      prettyPrint - Set to true for pretty print
      Returns:
      the output stream
    • getInputStream

      InputStream getInputStream(boolean prettyPrint)
      Gets the object as input stream.
      Parameters:
      prettyPrint - Set to true for pretty print
      Returns:
      the input stream
    • getReader

      Reader getReader(boolean prettyPrint) throws UnsupportedEncodingException
      Gets the object as reader.
      Parameters:
      prettyPrint - tSet to true for pretty print
      Returns:
      the reader
      Throws:
      UnsupportedEncodingException - the unsupported encoding exception
    • resetField

      void resetField(String field)
      Reset a field.
      Parameters:
      field - the field
    • getList

      List<Object> getList(String string)
      Gets the list of object from a field with list of values.
      Parameters:
      string - the string
      Returns:
      the list
    • isDateList

      boolean isDateList(String field)
      Checks if the field is list of dates.
      Parameters:
      field - the field
      Returns:
      true, if the field is date list
    • isNestedObjectList

      boolean isNestedObjectList(String field)
      Checks if the field is a list of nested objects
      Parameters:
      field - the field
      Returns:
      true, if the field is nested object list