All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.faktorips.runtime.IModelObjectDelta Maven / Gradle / Ivy

Go to download

Runtime library for Faktor-IPS. When using the JAXB support use either faktorips-runtime-jakarta-xml or faktorips-runtime-javax-xml as dependency. When using CSV to read tables, add the optional dependencies to opencsv, commons-lang3 and commons-text. If you want to run Faktor-IPS tests as JUnit tests, you need to provide either junit (JUnit 4) or junit-jupiter-api (JUnit 5).

There is a newer version: 25.1.0.a20241030-01
Show newest version
/*******************************************************************************
 * Copyright (c) Faktor Zehn GmbH - faktorzehn.org
 * 
 * This source code is available under the terms of the AGPL Affero General Public License version
 * 3.
 * 
 * Please see LICENSE.txt for full license terms, including the additional permissions and
 * restrictions as well as the possibility of alternative license terms.
 *******************************************************************************/

package org.faktorips.runtime;

import java.util.List;

import org.faktorips.runtime.model.type.AssociationKind;
import org.faktorips.runtime.model.type.PolicyCmptType;

/**
 * A model object delta represents the delta between two model objects. The two model objects must
 * be instances of the same model class. One typical use case is that the two (technical) objects
 * represent the same business object but at two different points in time.
 * 
 * @author Jan Ortmann
 */
public interface IModelObjectDelta {

    /**
     * Constant indicating that the delta is empty, no difference exists between the two objects.
     * 

* If the object is a root object, this means that all properties are equal, no children have * been removed, added or have changed their position. *

* If this object is a dependent object (it belongs to a parent), this means that all properties * are equal and this object has neither been added to or removed from its parent nor has the * position of the object changed. */ public static final int EMPTY = 0; /** * Delta kind constant indicating that the model object has been added to it's parent. */ public static final int ADDED = 16; /** * Delta kind constant indicating that the model object has been removed from it's parent. */ public static final int REMOVED = 8; /** * Delta kind constant indicating that the model object has been moved, meaning it's position in * the ordered list of objects has been changed. This type of delta is only returned if the * computation method is {@link IDeltaComputationOptions.ComputationMethod#BY_OBJECT}. *

* Note that an object can be moved and changed! In this case getKind() returns * {@code MOVED & CHANGED}. */ public static final int MOVED = 4; /** * Delta kind constant indicating that a different model object is now at a given position. This * type of delta is only returned if the computation method is * {@link IDeltaComputationOptions.ComputationMethod#BY_POSITION}. */ public static final int DIFFERENT_OBJECT_AT_POSITION = 2; /** * Delta kind constant indicating that the model object has changed somehow. If the object has * changed, the type of change is further specified with the following constants. Note that * these constants are bit masks as more than one type of change can occur. *

* Note that an object can be moved and changed! In this case getKind() returns * {@code MOVED & CHANGED}. * * @see #STRUCTURE_CHANGED * @see #PROPERTY_CHANGED * @see #CHILD_CHANGED */ public static final int CHANGED = 1; /** * Delta change type constant indicating that the object's structure has changed, that means * either a child has been added, removed or changed its position (if the computation method is * {@link IDeltaComputationOptions.ComputationMethod#BY_OBJECT} or a different object is now at * a given position (if the computation method is * {@link IDeltaComputationOptions.ComputationMethod#BY_OBJECT}. */ public static final int STRUCTURE_CHANGED = 1; /** * Delta change type constant indicating that at least one of the object's properties has * changed. */ public static final int PROPERTY_CHANGED = 2; /** * Delta change type constant indicating that at least one child (that has neither been added or * removed or just moved) has changed. Either one of the child's properties has changed or it's * structure (or both). */ public static final int CHILD_CHANGED = 4; /** * Delta change type constant indicating that the class of the object has changed. */ public static final int CLASS_CHANGED = 8; /** * 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. */ public IModelObject getOriginalObject(); /** * 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. */ public IModelObject getReferenceObject(); /** * 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! * * @see #EMPTY * @see #ADDED * @see #REMOVED * @see #MOVED * @see #DIFFERENT_OBJECT_AT_POSITION * @see #CHANGED */ public int getKind(); /** * If delta's kind is {@link #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 * {@link #CHANGED}. * * @see #PROPERTY_CHANGED * @see #STRUCTURE_CHANGED * @see #CHILD_CHANGED */ public int getKindOfChange(); /** * Returns true if the delta is empty, the two objects are the same, otherwise * false. */ public boolean isEmpty(); /** * Returns true if this model object has been added to its parent, * false otherwise. */ public boolean isAdded(); /** * Returns true if this model object has been removed from its parent, * false otherwise. */ public boolean isRemoved(); /** * 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 * {@link IDeltaComputationOptions.ComputationMethod#BY_OBJECT}. */ public boolean isMoved(); /** * 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 * {@link IDeltaComputationOptions.ComputationMethod#BY_POSITION}. */ public boolean isDifferentObjectAtPosition(); /** * Returns true if this model object has been changed. */ public boolean isChanged(); /** * 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. */ public boolean isStructureChanged(); /** * Returns true if the model object's Java class has "changed". (Technically its of * course just an instance of another class). Returns false otherwise. */ public boolean isClassChanged(); /** * Returns true if at least one the model object's properties has changed, * otherwise false. */ public boolean isPropertyChanged(); /** * Returns true if at least one model object's children has been changed. */ public boolean isChildChanged(); /** * The name of the association in which the object has been added, removed or changed. The * association name is always null for the root of the delta. */ public String getAssociation(); /** * 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. * * @return the {@link AssociationKind} or null if this is the root */ public AssociationKind getAssociationKind(); /** * Returns 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 {@link PolicyCmptType#getAttributes() * order defined in the model type}. Properties not manually defined in the model type, such as * the {@link IConfigurableModelObject#PROPERTY_PRODUCT_COMPONENT product component}, are placed * before manually defined attributes. */ public List getChangedProperties(); /** * Returns true if the model object contains a different value for the given * property than the reference model object. Returns false otherwise. Returns * false if propertyName is null. */ public boolean isPropertyChanged(String propertyName); /** * 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. */ public List getChildDeltas(); /** * 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. */ public List getChildDeltas(int kind); /** * Accepts the given visitor. *

* The visitor's visit method is called. If the visitor returns true, * the delta's children are also visited. * * @param visitor the visitor * * @throws NullPointerException if visitor is null. * * @see IModelObjectDeltaVisitor#visit(IModelObjectDelta) */ public void accept(IModelObjectDeltaVisitor visitor); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy