Package org.faktorips.runtime.internal
Class ModelObjectDelta
- java.lang.Object
-
- org.faktorips.runtime.internal.ModelObjectDelta
-
- All Implemented Interfaces:
IModelObjectDelta
public class ModelObjectDelta extends java.lang.Object implements IModelObjectDelta
IModelObjectDelta implementation.- Author:
- Jan Ortmann
-
-
Field Summary
-
Fields inherited from interface org.faktorips.runtime.IModelObjectDelta
ADDED, CHANGED, CHILD_CHANGED, CLASS_CHANGED, DIFFERENT_OBJECT_AT_POSITION, EMPTY, MOVED, PROPERTY_CHANGED, REMOVED, STRUCTURE_CHANGED
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaccept(IModelObjectDeltaVisitor visitor)Accepts the given visitor.voidaddChildDelta(IModelObjectDelta childDelta)Adds the child delta to this delta and sets this delta's kindOfChange accordingly.voidcheckPropertyChange(java.lang.String property, boolean value1, boolean value2, IDeltaComputationOptions options)voidcheckPropertyChange(java.lang.String property, char value1, char value2, IDeltaComputationOptions options)voidcheckPropertyChange(java.lang.String property, double value1, double value2, IDeltaComputationOptions options)voidcheckPropertyChange(java.lang.String property, float value1, float value2, IDeltaComputationOptions options)voidcheckPropertyChange(java.lang.String property, int value1, int value2, IDeltaComputationOptions options)voidcheckPropertyChange(java.lang.String property, java.lang.Object value1, java.lang.Object value2, IDeltaComputationOptions options)static voidcreateAssociatedChildDeltas(ModelObjectDelta delta, java.util.List<? extends IModelObject> originals, java.util.List<? extends IModelObject> refObjects, java.lang.String association, IDeltaComputationOptions options)static voidcreateAssociatedChildDeltas(ModelObjectDelta delta, IModelObject original, IModelObject refObject, java.lang.String association, IDeltaComputationOptions options)static voidcreateChildDeltas(ModelObjectDelta delta, java.util.List<? extends IModelObject> originals, java.util.List<? extends IModelObject> refObjects, java.lang.String association, IDeltaComputationOptions options)static voidcreateChildDeltas(ModelObjectDelta delta, IModelObject original, IModelObject refObject, java.lang.String association, IDeltaComputationOptions options)java.lang.StringgetAssociation()The name of the association in which the object has been added, removed or changed.AssociationKindgetAssociationKind()Returns the kind of association if this delta has any incoming association, that means it is part of a composite or the object is associated from another object.java.util.List<java.lang.String>getChangedProperties()Returns the properties that have a different value in the model object and the reference model object.java.util.List<IModelObjectDelta>getChildDeltas()Returns deltas for all children of the model object which were added, removed, or changed.java.util.List<IModelObjectDelta>getChildDeltas(int kind)Returns deltas for all children of this model object whose kind is included in the given mask.intgetKind()Returns the kind of change.intgetKindOfChange()If delta's kind isIModelObjectDelta.CHANGED, this method returns the kind of changed defined by the constant listed below.IModelObjectgetOriginalObject()The model object this delta is computed for.IModelObjectgetReferenceObject()The model object that is taken as a reference to which the orginal model object is compared to.booleanisAdded()Returnstrueif this model object has been added to its parent,falseotherwise.booleanisChanged()Returnstrueif this model object has been changed.booleanisChildChanged()Returnstrueif at least one model object's children has been changed.booleanisClassChanged()Returnstrueif the model object's Java class has "changed".booleanisDifferentObjectAtPosition()Returnstrueif a different model object is at a position, otherwisefalse.booleanisEmpty()Returnstrueif the delta is empty, the two objects are the same, otherwisefalse.booleanisMoved()Returnstrueif this model object has changed its position in the ordered association.booleanisPropertyChanged()Returnstrueif at least one the model object's properties has changed, otherwisefalse.booleanisPropertyChanged(java.lang.String propertyName)Returnstrueif the model object contains a different value for the given property than the reference model object.booleanisRemoved()Returnstrueif this model object has been removed from its parent,falseotherwise.booleanisStructureChanged()Returnstrueif this model object's structure has changed.voidmarkMoved()Marks the delta as one where the object has changed its position.voidmarkPropertyChanged(java.lang.String property)Marks the given property as having a different value in the model object and the reference model object.static ModelObjectDeltanewAddDelta(IModelObject addedObject, java.lang.String association, IDeltaComputationOptions options)Deprecated.since 19.12.static ModelObjectDeltanewAddDelta(IModelObject addedObject, java.lang.String association, AssociationKind associationKind, IDeltaComputationOptions options)static ModelObjectDeltanewChangeDelta(IModelObject original, IModelObject refObject, int kindOfChange)static ModelObjectDeltanewDelta(IModelObject object, IModelObject refObject, IDeltaComputationOptions options)static ModelObjectDeltanewDifferentObjectAtPositionChangedDelta(IModelObject original, IModelObject refObject, java.lang.String association)Deprecated.since 19.12.static ModelObjectDeltanewDifferentObjectAtPositionChangedDelta(IModelObject original, IModelObject refObject, java.lang.String association, AssociationKind associationKind)static ModelObjectDeltanewEmptyDelta(IModelObject object, IModelObject refObject)static ModelObjectDeltanewRemoveDelta(IModelObject removedObject, java.lang.String association, IDeltaComputationOptions options)Deprecated.since 19.12.static ModelObjectDeltanewRemoveDelta(IModelObject removedObject, java.lang.String association, AssociationKind associationKind, IDeltaComputationOptions options)voidsetAssociation(java.lang.String association)voidsetAssociationKind(AssociationKind associationKind)java.lang.StringtoString()voidtoString(java.lang.StringBuilder builder, java.lang.String indentation)
-
-
-
Method Detail
-
newDelta
public static final ModelObjectDelta newDelta(IModelObject object, IModelObject refObject, IDeltaComputationOptions options)
-
newEmptyDelta
public static final ModelObjectDelta newEmptyDelta(IModelObject object, IModelObject refObject)
-
createChildDeltas
public static final void createChildDeltas(ModelObjectDelta delta, IModelObject original, IModelObject refObject, java.lang.String association, IDeltaComputationOptions options)
-
createAssociatedChildDeltas
public static final void createAssociatedChildDeltas(ModelObjectDelta delta, IModelObject original, IModelObject refObject, java.lang.String association, IDeltaComputationOptions options)
-
createChildDeltas
public static final void createChildDeltas(ModelObjectDelta delta, java.util.List<? extends IModelObject> originals, java.util.List<? extends IModelObject> refObjects, java.lang.String association, IDeltaComputationOptions options)
-
createAssociatedChildDeltas
public static final void createAssociatedChildDeltas(ModelObjectDelta delta, java.util.List<? extends IModelObject> originals, java.util.List<? extends IModelObject> refObjects, java.lang.String association, IDeltaComputationOptions options)
-
newAddDelta
@Deprecated public static final ModelObjectDelta newAddDelta(IModelObject addedObject, java.lang.String association, IDeltaComputationOptions options)
Deprecated.since 19.12. UsenewAddDelta(IModelObject, String, AssociationKind, IDeltaComputationOptions)instead.
-
newAddDelta
public static final ModelObjectDelta newAddDelta(IModelObject addedObject, java.lang.String association, AssociationKind associationKind, IDeltaComputationOptions options)
-
newRemoveDelta
@Deprecated public static final ModelObjectDelta newRemoveDelta(IModelObject removedObject, java.lang.String association, IDeltaComputationOptions options)
Deprecated.since 19.12. UsenewRemoveDelta(IModelObject, String, AssociationKind, IDeltaComputationOptions)instead.
-
newRemoveDelta
public static final ModelObjectDelta newRemoveDelta(IModelObject removedObject, java.lang.String association, AssociationKind associationKind, IDeltaComputationOptions options)
-
newDifferentObjectAtPositionChangedDelta
@Deprecated public static final ModelObjectDelta newDifferentObjectAtPositionChangedDelta(IModelObject original, IModelObject refObject, java.lang.String association)
Deprecated.since 19.12. UsenewDifferentObjectAtPositionChangedDelta(IModelObject, IModelObject, String, AssociationKind)instead.
-
newDifferentObjectAtPositionChangedDelta
public static final ModelObjectDelta newDifferentObjectAtPositionChangedDelta(IModelObject original, IModelObject refObject, java.lang.String association, AssociationKind associationKind)
-
newChangeDelta
public static final ModelObjectDelta newChangeDelta(IModelObject original, IModelObject refObject, int kindOfChange)
-
addChildDelta
public void addChildDelta(IModelObjectDelta childDelta)
Adds the child delta to this delta and sets this delta's kindOfChange accordingly. E.g. if the child delta is of kind ADD, this delta's kind of change is marked as structure changed.Note this method ignores the childDelta if it is
nullor empty!!!
-
getOriginalObject
public IModelObject getOriginalObject()
Description copied from interface:IModelObjectDeltaThe model object this delta is computed for. If this is a delta for a a child that was added to the new object, the method returnsnull.- Specified by:
getOriginalObjectin interfaceIModelObjectDelta
-
getReferenceObject
public IModelObject getReferenceObject()
Description copied from interface:IModelObjectDeltaThe model object that is taken as a reference to which the orginal model object is compared to.If this is a delta for a a child that was removed from the orginial model object, the method returns
null.- Specified by:
getReferenceObjectin interfaceIModelObjectDelta
-
getKind
public int getKind()
Description copied from interface:IModelObjectDeltaReturns the kind of change. Note that an object can be moved and changed! To allow this type of information to be returned, a bit mask is used!- Specified by:
getKindin interfaceIModelObjectDelta- See Also:
IModelObjectDelta.EMPTY,IModelObjectDelta.ADDED,IModelObjectDelta.REMOVED,IModelObjectDelta.MOVED,IModelObjectDelta.DIFFERENT_OBJECT_AT_POSITION,IModelObjectDelta.CHANGED
-
getKindOfChange
public int getKindOfChange()
Description copied from interface:IModelObjectDeltaIf delta's kind isIModelObjectDelta.CHANGED, this method returns the kind of changed defined by the constant listed below. Not that the kind of changes are not mututally excluded, so the returned kinds are bit masked. The method returns 0, if the delta's kind is notIModelObjectDelta.CHANGED.- Specified by:
getKindOfChangein interfaceIModelObjectDelta- See Also:
IModelObjectDelta.PROPERTY_CHANGED,IModelObjectDelta.STRUCTURE_CHANGED,IModelObjectDelta.CHILD_CHANGED
-
getAssociation
public java.lang.String getAssociation()
Description copied from interface:IModelObjectDeltaThe name of the association in which the object has been added, removed or changed. The association name is alwaysnullfor the root of the delta.- Specified by:
getAssociationin interfaceIModelObjectDelta
-
setAssociation
public void setAssociation(java.lang.String association)
-
getAssociationKind
public AssociationKind getAssociationKind()
Description copied from interface:IModelObjectDeltaReturns the kind of association if this delta has any incoming association, that means it is part of a composite or the object is associated from another object.- Specified by:
getAssociationKindin interfaceIModelObjectDelta- Returns:
- the
AssociationKindornullif this is the root
-
setAssociationKind
public void setAssociationKind(AssociationKind associationKind)
-
checkPropertyChange
public void checkPropertyChange(java.lang.String property, java.lang.Object value1, java.lang.Object value2, IDeltaComputationOptions options)
-
checkPropertyChange
public void checkPropertyChange(java.lang.String property, int value1, int value2, IDeltaComputationOptions options)
-
checkPropertyChange
public void checkPropertyChange(java.lang.String property, boolean value1, boolean value2, IDeltaComputationOptions options)
-
checkPropertyChange
public void checkPropertyChange(java.lang.String property, double value1, double value2, IDeltaComputationOptions options)
-
checkPropertyChange
public void checkPropertyChange(java.lang.String property, float value1, float value2, IDeltaComputationOptions options)
-
checkPropertyChange
public void checkPropertyChange(java.lang.String property, char value1, char value2, IDeltaComputationOptions options)
-
markPropertyChanged
public void markPropertyChanged(java.lang.String property)
Marks the given property as having a different value in the model object and the reference model object.
-
isClassChanged
public boolean isClassChanged()
Description copied from interface:IModelObjectDeltaReturnstrueif the model object's Java class has "changed". (Technically its of course just an instance of another class). Returnsfalseotherwise.- Specified by:
isClassChangedin interfaceIModelObjectDelta
-
isPropertyChanged
public boolean isPropertyChanged()
Description copied from interface:IModelObjectDeltaReturnstrueif at least one the model object's properties has changed, otherwisefalse.- Specified by:
isPropertyChangedin interfaceIModelObjectDelta
-
getChangedProperties
public java.util.List<java.lang.String> getChangedProperties()
Description copied from interface:IModelObjectDeltaReturns the properties that have a different value in the model object and the reference model object. Returns an empty list if no such property exists.The order of properties in the list corresponds to the
order defined in the model type. Properties not manually defined in the model type, such as theproduct component, are placed before manually defined attributes.- Specified by:
getChangedPropertiesin interfaceIModelObjectDelta
-
isPropertyChanged
public boolean isPropertyChanged(java.lang.String propertyName)
Description copied from interface:IModelObjectDeltaReturnstrueif the model object contains a different value for the given property than the reference model object. Returnsfalseotherwise. Returnsfalseif propertyName isnull.- Specified by:
isPropertyChangedin interfaceIModelObjectDelta
-
markMoved
public void markMoved()
Marks the delta as one where the object has changed its position.
-
isMoved
public boolean isMoved()
Description copied from interface:IModelObjectDeltaReturnstrueif this model object has changed its position in the ordered association. This type of delta is only returned if the computation method isIDeltaComputationOptions.ComputationMethod.BY_OBJECT.- Specified by:
isMovedin interfaceIModelObjectDelta
-
isDifferentObjectAtPosition
public boolean isDifferentObjectAtPosition()
Description copied from interface:IModelObjectDeltaReturnstrueif a different model object is at a position, otherwisefalse. This type of delta is only returned if the computation method isIDeltaComputationOptions.ComputationMethod.BY_POSITION.- Specified by:
isDifferentObjectAtPositionin interfaceIModelObjectDelta
-
isAdded
public boolean isAdded()
Description copied from interface:IModelObjectDeltaReturnstrueif this model object has been added to its parent,falseotherwise.- Specified by:
isAddedin interfaceIModelObjectDelta
-
isChanged
public boolean isChanged()
Description copied from interface:IModelObjectDeltaReturnstrueif this model object has been changed.- Specified by:
isChangedin interfaceIModelObjectDelta
-
isChildChanged
public boolean isChildChanged()
Description copied from interface:IModelObjectDeltaReturnstrueif at least one model object's children has been changed.- Specified by:
isChildChangedin interfaceIModelObjectDelta
-
isEmpty
public boolean isEmpty()
Description copied from interface:IModelObjectDeltaReturnstrueif the delta is empty, the two objects are the same, otherwisefalse.- Specified by:
isEmptyin interfaceIModelObjectDelta
-
isRemoved
public boolean isRemoved()
Description copied from interface:IModelObjectDeltaReturnstrueif this model object has been removed from its parent,falseotherwise.- Specified by:
isRemovedin interfaceIModelObjectDelta
-
isStructureChanged
public boolean isStructureChanged()
Description copied from interface:IModelObjectDeltaReturnstrueif this model object's structure has changed. That means either a child has been added or removed or a child has been been moved.- Specified by:
isStructureChangedin interfaceIModelObjectDelta
-
getChildDeltas
public java.util.List<IModelObjectDelta> getChildDeltas()
Description copied from interface:IModelObjectDeltaReturns deltas for all children of the model object which were added, removed, or changed. Returns an empty array if there are no affected children.- Specified by:
getChildDeltasin interfaceIModelObjectDelta
-
getChildDeltas
public java.util.List<IModelObjectDelta> getChildDeltas(int kind)
Description copied from interface:IModelObjectDeltaReturns deltas for all children of this model object whose kind is included in the given mask. Kind masks are formed by the bitwise or ofIModelObjectDeltakind constants. Returns an empty array if there are no affected children.- Specified by:
getChildDeltasin interfaceIModelObjectDelta
-
accept
public void accept(IModelObjectDeltaVisitor visitor)
Description copied from interface:IModelObjectDeltaAccepts the given visitor.The visitor's
visitmethod is called. If the visitor returnstrue, the delta's children are also visited.- Specified by:
acceptin interfaceIModelObjectDelta- Parameters:
visitor- the visitor- See Also:
IModelObjectDeltaVisitor.visit(IModelObjectDelta)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public void toString(java.lang.StringBuilder builder, java.lang.String indentation)
-
-