Class ModelDiffConfig
java.lang.Object
com.onenetwork.platform.data.model.ModelDiffConfig
public class ModelDiffConfig
extends java.lang.Object
Class representing configurable options for finding out differences between two
Available configuration options are
Model
objects.
Available configuration options are
- ignoreNullModel1Fields: A boolean value, if set to true, fields from first model object for which value is null should not be compared with field values from second model object. Default value is false.
- recurseChildLevels: A boolean value, if set to true, child level model objects of passed model objects will
be also compared, if child level model objects are available. Default value is false.
There is no guarantee of sequence in which child model objects are processed while finding out differences. If length of child model list is not equal then difference for this inequality will be also returned.
e.g. Two Order objects(Order1 and Order2) need to be compared. Order1 has two child objects of type OrderLineItem and Order2 has four child objects of type OrderLineItem.
In this case, first two child objects from each child list of Order1 and Order2 will be compared and for two remaining child objects in Order2, aDifference
will be created with field values asfieldName
: OrderLineItems i.e. pluralized child level namemodel1Value
: nullmodel2Value
:List
containing references of last two childs in Order2. - considerNullConstantsAsNull: A boolean value, if set to true, fields with unset and null constant values should also be considered null. Default value is true.
- ignoreCoreFieldChanges: A boolean value, if set to true, automatically generated core model fields by default will be ignored. These core fields are ModelName, CreationUser, CreationDate, LastModifiedUser, LastModifiedDate, LastComputedDate, LastTouchedDate, LevelModifiedDate, ValueChainId, LevelCreationDate. Default value is true.
- fields: An optional list of field names which should only be compared while finding out differences,
other fields will be ignored. If not provided then all fields will be compared.
It can also contain field names from child level as well if recurseChildLevels is set to true.
Supported field categories are PDF, MDF and UDF. All field types are supported except Attachments and Attached Notes.
In case of composite field, fields can contain composite field name and/or component names of the composite field.
For composite field, all the components will be compared and difference will be returned if value of any component is not equal. The returnedDifference
object will have composite field name as fieldName , for which difference was found, and composite values as model values.
For component field, values of component field will be compared individually. If values are not equal then returnedDifference
object will have component field name as fieldName , for which difference was found, and component values as model values.
For details, referModel.diff(Model, ModelDiffConfig)
- See Also:
Difference
-
Constructor Summary
Constructors Constructor Description ModelDiffConfig()
Creates ModelDiffConfig with defaults.ModelDiffConfig(boolean ignoreNullModel1Fields, boolean recurseChildLevels, java.lang.String... fields)
ModelDiffConfig(boolean ignoreNullModel1Fields, boolean recurseChildLevels, java.util.List<java.lang.String> fields)
ModelDiffConfig(java.lang.String... fields)
Creates DiffConfig for diffing provided fields -
Method Summary
Modifier and Type Method Description java.util.List<java.lang.String>
getFields()
boolean
isConsiderNullConstantsAsNull()
boolean
isIgnoreCoreFieldChanges()
boolean
isIgnoreNullModel1Fields()
boolean
isRecurseChildLevels()
void
setConsiderNullConstantsAsNull(boolean considerNullConstantsAsNull)
void
setFields(java.util.List<java.lang.String> fields)
void
setIgnoreCoreFieldChanges(boolean ignoreCoreFieldChanges)
void
setIgnoreNullModel1Fields(boolean ignoreNullModel1Fields)
void
setRecurseChildLevels(boolean recurseChildLevels)
-
Constructor Details
-
ModelDiffConfig
public ModelDiffConfig()Creates ModelDiffConfig with defaults. -
ModelDiffConfig
public ModelDiffConfig(boolean ignoreNullModel1Fields, boolean recurseChildLevels, java.util.List<java.lang.String> fields)- Parameters:
ignoreNullModel1Fields
- if set to true, field with null values on first model instance are ignored for diffrecurseChildLevels
- if set to true, child level model objects are also diffedfields
- list of field names to be diffed, if null all fields will be diffed
-
ModelDiffConfig
public ModelDiffConfig(boolean ignoreNullModel1Fields, boolean recurseChildLevels, java.lang.String... fields)- Parameters:
ignoreNullModel1Fields
- if set to true, field with null values on first model instance are ignored for diffrecurseChildLevels
- if set to true, child level model objects are also diffedfields
- field names to be diffed, if null all fields will be diffed
-
ModelDiffConfig
public ModelDiffConfig(java.lang.String... fields)Creates DiffConfig for diffing provided fields- Parameters:
fields
- field names to be diffed, if null all fields will be diffed
-
-
Method Details
-
isIgnoreNullModel1Fields
public boolean isIgnoreNullModel1Fields() -
setIgnoreNullModel1Fields
public void setIgnoreNullModel1Fields(boolean ignoreNullModel1Fields)- Parameters:
ignoreNullModel1Fields
- if set to true, field with null values on first model instance are ignored for diff
-
isRecurseChildLevels
public boolean isRecurseChildLevels() -
setRecurseChildLevels
public void setRecurseChildLevels(boolean recurseChildLevels)- Parameters:
recurseChildLevels
- if set to true, child level model objects are also diffed
-
isConsiderNullConstantsAsNull
public boolean isConsiderNullConstantsAsNull() -
setConsiderNullConstantsAsNull
public void setConsiderNullConstantsAsNull(boolean considerNullConstantsAsNull)- Parameters:
considerNullConstantsAsNull
- if set to true, field type's unset and null constants are considered null
-
isIgnoreCoreFieldChanges
public boolean isIgnoreCoreFieldChanges() -
setIgnoreCoreFieldChanges
public void setIgnoreCoreFieldChanges(boolean ignoreCoreFieldChanges)- Parameters:
ignoreCoreFieldChanges
- if set to true, automatically generated core model fields will not be diffed.
-
getFields
public java.util.List<java.lang.String> getFields() -
setFields
public void setFields(java.util.List<java.lang.String> fields)- Parameters:
fields
- list of field names to be diffed, if null all fields will be diffed
-