Package eu.c6.gibraltar.api.common
Interface ICObject
- All Superinterfaces:
Cloneable,Serializable
- 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
The Interface ICObject to manage internal JSON content.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIntoList(String fieldOrPath, Collection<?> values) Append values into a field with a list of values.voidaddValueIntoList(String fieldOrPath, Object value) Append value into a field with a list of values.voidClear list values.clone()Clone the object.<T extends ICObject>
TClone the object as new class.<T extends ICObject>
TClone the object as new class.booleanChecks if object contains a field with specified value.booleancontainsField(String fieldOrPath) Check if object contains a field.booleanChecks if current object is equals to another.Gets the object value.booleangetBoolean(String fieldOrPath) Gets the boolean value.booleangetBoolean(String fieldOrPath, boolean def) Gets the boolean value.Gets the date value or NULL if field does not exsit.Gets the date value.doubleGets the double value or 0 if field does not exist.doubleGets the double value.Gets the direct field names as iterator.Gets the field names flatten list of all fields recursively.Gets the field names list.getInputStream(boolean prettyPrint) Gets the object as input stream.intGets the integer value.intGets the integer value.Gets the list of object from a field with list of values.getListNestedObject(String fieldOrPath) Gets the list of nested objects.<T> List<T>getListNestedObject(String fieldOrPath, Class<T> clazz) Returns a list of values instantiated as the Class passed as parameters.<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.getListNestedObjectByAttribute(String fieldOrPath, String nestedFieldName, String fieldValue) Gets the list nested object filtered by nested object field value.<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.intgetListSize(String fieldOrPath) Gets the list size of a field with a list of values..getListString(String fieldOrPath) Gets the list of string.getLocalDateTime(String fieldOrPath) Gets the local date time value or NULL if field does not exist.getLocalDateTime(String fieldOrPath, LocalDateTime def) Gets the local date time value.longGets the long value or 0 if field does not exist.longGets the long value.getNestedObject(String fieldOrPath) Gets the nested object.<T extends ICObject>
TgetNestedObject(String fieldOrPath, Class<T> clazz) Gets the nested object instantiated with a provided class.<T extends ICObject>
TgetNestedObject(String fieldOrPath, Class<T> clazz, Class<? extends T> implClazz) Gets the nested object instantiated with a provided class.Gets the nested object field names list.getOutputStream(boolean prettyPrint) Gets the object as output stream.getReader(boolean prettyPrint) Gets the object as reader.Gets the string value or NULL if field does not exist.Gets the string value.voidinsertIntoList(String fieldOrPath, Object value, int i) Insert a value into a field with a list of values at the specified index.booleanChecks if a field is a boolean.booleanChecks if the field is a date.booleanisDateList(String field) Checks if the field is list of dates.booleanChecks if the field is a double.booleanisEmpty()Checks if the field is object empty.booleanisFieldEmpty(String fieldOrPath) Checks if the field is empty.booleanChecks if the field is an integer.booleanChecks if the field is a list.booleanisNestedObject(String fieldOrPath) Checks if the field is a nested object.booleanisNestedObjectList(String field) Checks if the field is a list of nested objectsbooleanChecks if the field is a string.Load object from another instance of ICObject.load(InputStream input) Load object from input JSON stream.voidMerge another instance of ICObject into this object.Merge deeply another instance of ICObject into this object.Compared to merge(), this method merges every values and is not limited to tree nodes.voidRemoves the field.voidremoveFromList(String fieldOrPath, Collection<?> values) Removes values from list values of a field.voidremoveValueFromList(String fieldOrPath, Object toBeRemovedValue) Removes the value from list values of a field.voidreplaceIntoList(String fieldOrPath, Object value, int i) Replaces a value into a field with a list of values using index.voidresetField(String field) Reset a field.voidSets the field typed value.voidSets the double value.voidSets the long value.voidSets the field typed value.voidSets the field typed value.voidSets the string value.voidset(String fieldOrPath, LocalDateTime value) Sets the local date time value.voidSets the date value.voidSets the field value with a new nested object created from a Map.voidsetList(String fieldOrPath, Collection<?> values) Sets the list values.voidSets the null value.Convert to text value.Get map of flatten names with values.toJson()Convert object to a JSON string formated.toMap()Convert object to a map.toString()Convert object to a string.toString(boolean autoIndent) Convert to string with auto indentation.
-
Field Details
-
FIELD_SEPARATOR_PATH
The field separator path.- See Also:
-
FIELD_SEPARATOR_DOT
The field separator dot.- See Also:
-
CHARSET
The charset used.
-
-
Method Details
-
isEmpty
boolean isEmpty()Checks if the field is object empty.- Returns:
- true, if empty
-
isBoolean
Checks if a field is a boolean.- Parameters:
fieldOrPath- the field name or field path- Returns:
- true, if the field is boolean
-
isDate
Checks if the field is a date.- Parameters:
fieldOrPath- the field name or field path- Returns:
- true, if the field is date
-
isString
Checks if the field is a string.- Parameters:
fieldOrPath- the field name or field path- Returns:
- true, if the field is string
-
isInt
Checks if the field is an integer.- Parameters:
fieldOrPath- the field name or field path- Returns:
- true, if the field is int
-
isDouble
Checks if the field is a double.- Parameters:
fieldOrPath- the field name or field path- Returns:
- true, if the field is double
-
containsField
Check if object contains a field.- Parameters:
fieldOrPath- the field name or field path to search- Returns:
- true, if the field exists
-
getBoolean
Gets the boolean value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the boolean value
-
getBoolean
Gets the boolean value.- Parameters:
fieldOrPath- the field name or field path- Returns:
- the boolean value or false if field does not exist
-
get
Gets the object value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the object value
-
set
Sets the field typed value.- Parameters:
fieldOrPath- the field name or field pathvalue- the typed value
-
set
Sets the field typed value.- Parameters:
fieldOrPath- the field name or field pathvalue- the typed value
-
set
Sets the field typed value.- Parameters:
fieldOrPath- the field name or field pathvalue- the typed value
-
set
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 pathvalues- the values converted to a nested object
-
setNull
Sets the null value.- Parameters:
fieldOrPath- the field name or field path
-
getInt
Gets the integer value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the integer value
-
getInt
Gets the integer value.- Parameters:
fieldOrPath- the field name or field path- Returns:
- the integer value or 0
-
getLong
Gets the long value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the long value
-
getLong
Gets the long value or 0 if field does not exist.- Parameters:
field- the field- Returns:
- the long value or 0
-
set
Sets the long value.- Parameters:
fieldOrPath- the field name or field pathvalue- the value
-
getDouble
Gets the double value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the double value
-
getDouble
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
Sets the double value.- Parameters:
fieldOrPath- the field name or field pathvalue- the value
-
getString
Gets the string value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the string value
-
getString
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
Sets the string value.- Parameters:
fieldOrPath- the field name or field pathvalue- the value
-
getDate
Gets the date value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the date value
-
getDate
Gets the date value or NULL if field does not exsit.- Parameters:
field- the field- Returns:
- the date value or NULL
-
set
Sets the date value.- Parameters:
fieldOrPath- the field name or field pathvalue- the value
-
getLocalDateTime
Gets the local date time value.- Parameters:
fieldOrPath- the field name or field pathdef- the default value if field does not exist- Returns:
- the local date time
-
getLocalDateTime
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
Sets the local date time value.- Parameters:
fieldOrPath- the field name or field pathvalue- the value
-
getListString
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
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
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
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 listnestedFieldName- the field name to test on nested objectsfieldValue- 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 listnestedFieldName- the field name to test on nested objectsfieldValue- 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
Checks if the field is a list.- Parameters:
fieldOrPath- the field name or field path- Returns:
- true, if the field is a list
-
isNestedObject
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
Sets the list values.- Parameters:
fieldOrPath- the field name or field pathvalues- the values
-
clearList
Clear list values.- Parameters:
fieldOrPath- the field name or field path
-
remove
Removes the field.- Parameters:
fieldOrPath- the field name or field path
-
toMap
Convert object to a map.- Returns:
- the map
-
toString
String toString()Convert object to a string. -
toJson
String toJson()Convert object to a JSON string formated.- Returns:
- the string
-
getFieldNames
Gets the direct field names as iterator.- Returns:
- the field names iterator
-
getFieldNamesList
Gets the field names list.- Returns:
- the field names list
-
getNestedObjectNamesList
Gets the nested object field names list.- Returns:
- the list of field names containing a nested object
-
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
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
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 pathclazz- the class interfaceimplClazz- the implementation class- Returns:
- the nested object
-
contains
Checks if object contains a field with specified value.- Parameters:
fieldOrPath- the field name or field pathvalue- the value- Returns:
- true, if successful
-
getNestedObject
Gets the nested object instantiated with a provided class.- Type Parameters:
T- the generic type- Parameters:
fieldOrPath- the field name or field pathclazz- the implementation or interface class- Returns:
- the nested object
-
load
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
Load object from another instance of ICObject.- Parameters:
obj- the object to copy- Returns:
- the object loaded
-
merge
Merge another instance of ICObject into this object. The merge adds missing fields and overwrite existings ones.- Parameters:
jsonPlugin- the json plugin
-
mergeDeep
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 mergekeepExisting- : if set to true, any value existing in the source object won't be overriden by the json provided in parameterskipEmpty- : 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
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
Checks if current object is equals to another. -
removeFromList
Removes values from list values of a field.- Parameters:
fieldOrPath- the field name or field pathvalues- the values to remove
-
replaceIntoList
Replaces a value into a field with a list of values using index.- Parameters:
fieldOrPath- the field name or field pathvalue- the value to seti- the index to replace into the list of values
-
removeValueFromList
Removes the value from list values of a field.- Parameters:
fieldOrPath- the field name or field pathtoBeRemovedValue- the value to be removed
-
addIntoList
Append values into a field with a list of values.- Parameters:
fieldOrPath- the field name or field pathvalues- the values
-
addValueIntoList
Append value into a field with a list of values.- Parameters:
fieldOrPath- the field name or field pathvalue- the value
-
insertIntoList
Insert a value into a field with a list of values at the specified index.- Parameters:
fieldOrPath- the field name or field pathvalue- the valuei- the index
-
getListSize
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
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
Clone the object as new class.- Type Parameters:
T- the generic type- Parameters:
clazz- the interface to implement the cloneimplClazz- the class to implement the clone- Returns:
- the cloned object instance of provided class
-
toString
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
Gets the object as output stream.- Parameters:
prettyPrint- Set to true for pretty print- Returns:
- the output stream
-
getInputStream
Gets the object as input stream.- Parameters:
prettyPrint- Set to true for pretty print- Returns:
- the input stream
-
getReader
Gets the object as reader.- Parameters:
prettyPrint- tSet to true for pretty print- Returns:
- the reader
- Throws:
UnsupportedEncodingException- the unsupported encoding exception
-
resetField
Reset a field.- Parameters:
field- the field
-
getList
Gets the list of object from a field with list of values.- Parameters:
string- the string- Returns:
- the list
-
isDateList
Checks if the field is list of dates.- Parameters:
field- the field- Returns:
- true, if the field is date list
-
isNestedObjectList
Checks if the field is a list of nested objects- Parameters:
field- the field- Returns:
- true, if the field is nested object list
-