org.faktorips.runtime.internal
Class ModelObjectDelta

java.lang.Object
  extended by org.faktorips.runtime.internal.ModelObjectDelta
All Implemented Interfaces:
IModelObjectDelta

public class ModelObjectDelta
extends 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
 void accept(IModelObjectDeltaVisitor visitor)
          Accepts the given visitor.
 void addChildDelta(IModelObjectDelta childDelta)
          Adds the child delta to this delta and sets this delta's kindOfChange accordingly.
 void checkPropertyChange(String property, boolean value1, boolean value2, IDeltaComputationOptions options)
           
 void checkPropertyChange(String property, char value1, char value2, IDeltaComputationOptions options)
           
 void checkPropertyChange(String property, double value1, double value2, IDeltaComputationOptions options)
           
 void checkPropertyChange(String property, float value1, float value2, IDeltaComputationOptions options)
           
 void checkPropertyChange(String property, int value1, int value2, IDeltaComputationOptions options)
           
 void checkPropertyChange(String property, Object value1, Object value2, IDeltaComputationOptions options)
           
static void createChildDeltas(ModelObjectDelta delta, IModelObject original, IModelObject refObject, String association, IDeltaComputationOptions options)
           
static void createChildDeltas(ModelObjectDelta delta, List<? extends IModelObject> originals, List<? extends IModelObject> refObjects, String association, IDeltaComputationOptions options)
           
 String getAssociation()
          The name of the association to that the object has been added / has been removed from or is moved in.
 List<String> getChangedProperties()
          Returns the properties that have a different a value in the model object and the reference model object.
 List<IModelObjectDelta> getChildDeltas()
          Returns deltas for all children of the model object which were added, removed, or changed.
 List<IModelObjectDelta> getChildDeltas(int kind)
          Returns deltas for all children of this model object whose kind is included in the given mask.
 int getKind()
          Returns the kind of change.
 int getKindOfChange()
          If delta's kind is IModelObjectDelta.CHANGED, this method returns the kind of changed defined by the constant listed below.
 IModelObject getOriginalObject()
          The model object this delta is computed for.
 IModelObject getReferenceObject()
          The model object that is taken as a reference to which the orginal model object is compared to.
 boolean isAdded()
          Returns true if this model object has been added to its parent, false otherwise.
 boolean isChanged()
          Returns true if this model object has been changed.
 boolean isChildChanged()
          Returns true if at least one model object's children has been changed.
 boolean isClassChanged()
          Returns true if the model object's Java class has "changed".
 boolean isDifferentObjectAtPosition()
          Returns true if a different model object is at a position, otherwise false.
 boolean isEmpty()
          Returns true if the delta is empty, the two objects are the same, otherwise false.
 boolean isMoved()
          Returns true if this model object has changed its position in the ordered association.
 boolean isPropertyChanged()
          Returns true if at least one the model object's properties has changed, otherwise false.
 boolean isPropertyChanged(String propertyName)
          Returns true if the model object contains a different value for the given property than then reference model object.
 boolean isRemoved()
          Returns true if this model object has been removed from its parent, false otherwise.
 boolean isStructureChanged()
          Returns true if this model object's structure has changed.
 void markMoved()
          Marks the delta as one where the object has changed its position.
 void markPropertyChanged(String property)
          Marks the given property as having a different value in the model object and the reference model object.
static ModelObjectDelta newAddDelta(IModelObject addedObject, String association, IDeltaComputationOptions options)
           
static ModelObjectDelta newChangeDelta(IModelObject original, IModelObject refObject, int kindOfChange)
           
static ModelObjectDelta newDelta(IModelObject object, IModelObject refObject, IDeltaComputationOptions options)
           
static ModelObjectDelta newDifferentObjectAtPositionChangedDelta(IModelObject original, IModelObject refObject, String association)
           
static ModelObjectDelta newEmptyDelta(IModelObject object, IModelObject refObject)
           
static ModelObjectDelta newRemoveDelta(IModelObject removedObject, String association, IDeltaComputationOptions options)
           
 String toString()
           
 void toString(StringBuffer buffer, String indentation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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,
                                           String association,
                                           IDeltaComputationOptions options)

createChildDeltas

public static final void createChildDeltas(ModelObjectDelta delta,
                                           List<? extends IModelObject> originals,
                                           List<? extends IModelObject> refObjects,
                                           String association,
                                           IDeltaComputationOptions options)

newAddDelta

public static final ModelObjectDelta newAddDelta(IModelObject addedObject,
                                                 String association,
                                                 IDeltaComputationOptions options)

newRemoveDelta

public static final ModelObjectDelta newRemoveDelta(IModelObject removedObject,
                                                    String association,
                                                    IDeltaComputationOptions options)

newDifferentObjectAtPositionChangedDelta

public static final ModelObjectDelta newDifferentObjectAtPositionChangedDelta(IModelObject original,
                                                                              IModelObject refObject,
                                                                              String association)

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 null or empty!!!


getOriginalObject

public IModelObject getOriginalObject()
Description copied from interface: IModelObjectDelta
The 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 returns null.

Specified by:
getOriginalObject in interface IModelObjectDelta

getReferenceObject

public IModelObject getReferenceObject()
Description copied from interface: IModelObjectDelta
The 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:
getReferenceObject in interface IModelObjectDelta

getKind

public int getKind()
Description copied from interface: IModelObjectDelta
Returns 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:
getKind in interface IModelObjectDelta
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: IModelObjectDelta
If delta's kind is IModelObjectDelta.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 not IModelObjectDelta.CHANGED.

Specified by:
getKindOfChange in interface IModelObjectDelta
See Also:
IModelObjectDelta.PROPERTY_CHANGED, IModelObjectDelta.STRUCTURE_CHANGED, IModelObjectDelta.CHILD_CHANGED

getAssociation

public String getAssociation()
Description copied from interface: IModelObjectDelta
The name of the association to that the object has been added / has been removed from or is moved in.

Specified by:
getAssociation in interface IModelObjectDelta

checkPropertyChange

public void checkPropertyChange(String property,
                                Object value1,
                                Object value2,
                                IDeltaComputationOptions options)

checkPropertyChange

public void checkPropertyChange(String property,
                                int value1,
                                int value2,
                                IDeltaComputationOptions options)

checkPropertyChange

public void checkPropertyChange(String property,
                                boolean value1,
                                boolean value2,
                                IDeltaComputationOptions options)

checkPropertyChange

public void checkPropertyChange(String property,
                                double value1,
                                double value2,
                                IDeltaComputationOptions options)

checkPropertyChange

public void checkPropertyChange(String property,
                                float value1,
                                float value2,
                                IDeltaComputationOptions options)

checkPropertyChange

public void checkPropertyChange(String property,
                                char value1,
                                char value2,
                                IDeltaComputationOptions options)

markPropertyChanged

public void markPropertyChanged(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: IModelObjectDelta
Returns true if the model object's Java class has "changed". (Technically its of course just an instance of another class). Returns false otherwise.

Specified by:
isClassChanged in interface IModelObjectDelta

isPropertyChanged

public boolean isPropertyChanged()
Description copied from interface: IModelObjectDelta
Returns true if at least one the model object's properties has changed, otherwise false.

Specified by:
isPropertyChanged in interface IModelObjectDelta

getChangedProperties

public List<String> getChangedProperties()
Description copied from interface: IModelObjectDelta
Returns the properties that have a different a value in the model object and the reference model object. Returns an empty array if no such property exists.

Specified by:
getChangedProperties in interface IModelObjectDelta

isPropertyChanged

public boolean isPropertyChanged(String propertyName)
Description copied from interface: IModelObjectDelta
Returns true if the model object contains a different value for the given property than then reference model object. Returns false otherwise. Returns false if propertyName is null.

Specified by:
isPropertyChanged in interface IModelObjectDelta

markMoved

public void markMoved()
Marks the delta as one where the object has changed its position.


isMoved

public boolean isMoved()
Description copied from interface: IModelObjectDelta
Returns true if this model object has changed its position in the ordered association. This type of delta is only returned if the computation method is IDeltaComputationOptions.ComputationMethod.BY_OBJECT.

Specified by:
isMoved in interface IModelObjectDelta

isDifferentObjectAtPosition

public boolean isDifferentObjectAtPosition()
Description copied from interface: IModelObjectDelta
Returns true if a different model object is at a position, otherwise false. This type of delta is only returned if the computation method is IDeltaComputationOptions.ComputationMethod.BY_POSITION.

Specified by:
isDifferentObjectAtPosition in interface IModelObjectDelta

isAdded

public boolean isAdded()
Description copied from interface: IModelObjectDelta
Returns true if this model object has been added to its parent, false otherwise.

Specified by:
isAdded in interface IModelObjectDelta

isChanged

public boolean isChanged()
Description copied from interface: IModelObjectDelta
Returns true if this model object has been changed.

Specified by:
isChanged in interface IModelObjectDelta

isChildChanged

public boolean isChildChanged()
Description copied from interface: IModelObjectDelta
Returns true if at least one model object's children has been changed.

Specified by:
isChildChanged in interface IModelObjectDelta

isEmpty

public boolean isEmpty()
Description copied from interface: IModelObjectDelta
Returns true if the delta is empty, the two objects are the same, otherwise false.

Specified by:
isEmpty in interface IModelObjectDelta

isRemoved

public boolean isRemoved()
Description copied from interface: IModelObjectDelta
Returns true if this model object has been removed from its parent, false otherwise.

Specified by:
isRemoved in interface IModelObjectDelta

isStructureChanged

public boolean isStructureChanged()
Description copied from interface: IModelObjectDelta
Returns true if 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:
isStructureChanged in interface IModelObjectDelta

getChildDeltas

public List<IModelObjectDelta> getChildDeltas()
Description copied from interface: IModelObjectDelta
Returns 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:
getChildDeltas in interface IModelObjectDelta

getChildDeltas

public List<IModelObjectDelta> getChildDeltas(int kind)
Description copied from interface: IModelObjectDelta
Returns deltas for all children of this model object whose kind is included in the given mask. Kind masks are formed by the bitwise or of IModelObjectDelta kind constants. Returns an empty array if there are no affected children.

Specified by:
getChildDeltas in interface IModelObjectDelta

accept

public void accept(IModelObjectDeltaVisitor visitor)
Description copied from interface: IModelObjectDelta
Accepts the given visitor.

The visitor's visit method is called. If the visitor returns true, the delta's children are also visited.

Specified by:
accept in interface IModelObjectDelta
Parameters:
visitor - the visitor
See Also:
IModelObjectDeltaVisitor.visit(IModelObjectDelta)

toString

public String toString()
Overrides:
toString in class Object

toString

public void toString(StringBuffer buffer,
                     String indentation)


Copyright © 2015. All rights reserved.