org.electrocodeogram.cpc.reconciler.api.strategy
Interface IReconcilerStrategy


public interface IReconcilerStrategy

Interface for IReconcilerProvider reconciliation strategies.

Every implementation needs to provide a no-argument constructor.

Implementations of this interface are treated as Singletons. An instance of each strategy will be generated at startup and will then be reused whenever needed.

Author:
vw
See Also:
IReconcilerProvider, IReconciliationResult

Nested Class Summary
static class IReconcilerStrategy.Status
          Return status indicator for reconcile(ICloneFile, List, String, String, List, LinkedList, IReconciliationResult).
 
Method Summary
 IReconcilerStrategy.Status reconcile(ICloneFile cloneFile, java.util.List<IClone> persistedClones, java.lang.String persistedFileContent, java.lang.String newFileContent, java.util.List<IDiffResult> differences, java.util.LinkedList<IClone> pendingClones, IReconciliationResult result)
          This method is called for each registered reconciliation strategy in turn (in order of their priority) until one method returns IReconcilerStrategy.Status.BREAK or all strategies have been called.
 

Method Detail

reconcile

IReconcilerStrategy.Status reconcile(ICloneFile cloneFile,
                                     java.util.List<IClone> persistedClones,
                                     java.lang.String persistedFileContent,
                                     java.lang.String newFileContent,
                                     java.util.List<IDiffResult> differences,
                                     java.util.LinkedList<IClone> pendingClones,
                                     IReconciliationResult result)
This method is called for each registered reconciliation strategy in turn (in order of their priority) until one method returns IReconcilerStrategy.Status.BREAK or all strategies have been called.

Only the pendingClones and result parameters may be modified.
All other parameters are to be considered read only.

A clone to be added to the result may only be taken from the pendingClones list or from within the result object. As only that list and the result object are guaranteed to contain cloned instances.
The elements of the persistedClones list are not cloned and may not be modified.
A strategy must not clone any objects itself.

A strategy should ignore any clone which it can't find. Only clones which were definitely removed should be added to the IReconciliationResult removed clones list.
Once all strategies have been run or one strategy returned IReconcilerStrategy.Status.BREAK, all remaining clones in the pendingClones list, will be added to the lost clones list automatically.

Parameters:
cloneFile - the clone file which was modified, never null.
persistedClones - the currently persisted clone data for the file, never null. Clone list is sorted by start offset.
persistedFileContent - the currently persisted content for the file, may be NULL.
newFileContent - the new content which was produced by some external modification to the file, may be NULL.
differences - the differences between the persisted and the new file content, never null. Differences are sorted by start offset.
pendingClones - a list of clones which have not yet been reconciled, this is the "todo list" for each strategy. A strategy should remove any clones which it adds to the result from this list. Clone list is sorted by start offset. This is the only parameter besides result which may be modified.
result - the current, incrementally filled IReconciliationResult. This is the only parameter besides pendingClones which may be modified.
Returns:
a status flag indicating the type of modifications done by this strategy.