Package org.eclipse.emf.spi.cdo

# Class DefaultCDOMerger

java.lang.Object
org.eclipse.emf.spi.cdo.DefaultCDOMerger

All Implemented Interfaces:
  `CDOMerger`, `CDOMergerBaseAware`

Direct Known Subclasses:
  `DefaultCDOMerger.PerFeature`

public class DefaultCDOMerger extends Object implements CDOMergerBaseAware
Default three-way merger for CDO change sets.

The first (`target`) change set describes the current branch or transaction into which the result will be applied. In `CDOMergingConflictResolver` this is the local transaction history. The second (`source`) change set describes the branch or repository history being merged.

Ordinary conflict-resolution histories share one start state. Automatic branch remerge can instead select different source and target bases. The branch transaction path therefore supplies both original base providers plus the actual result base. The semantic many-valued merger preserves that causal asymmetry so occurrences absent from one side's base are treated as unobserved rather than synthesized as removals. The richer branch/remerge entry point also normalizes every returned NEW, CHANGED, and DETACHED goal to the selected result base; `CDOTransactionImpl.applyChangeSet()` subsequently reconciles that goal with the actual target state.

CDO's internal producers retain the revision providers needed by the semantic many-valued merger. That richer call-local context provides full base values to distinguish equal list occurrences and the base set-state of unsettable features without storing repository/session state on this reusable merger instance.

Since:
  3.0
Author:
  Eike Stepper

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`DefaultCDOMerger.ChangedInSourceAndDetachedInTargetConflict`
If the meaning of this type isn't clear, there really should be more of a description here...
`static class`
`DefaultCDOMerger.ChangedInSourceAndTargetConflict`
If the meaning of this type isn't clear, there really should be more of a description here...
`static class`
`DefaultCDOMerger.ChangedInTargetAndDetachedInSourceConflict`
If the meaning of this type isn't clear, there really should be more of a description here...
`static class`
`DefaultCDOMerger.Conflict`
If the meaning of this type isn't clear, there really should be more of a description here...
`static class`
`DefaultCDOMerger.PerFeature`
If the meaning of this type isn't clear, there really should be more of a description here...
`static enum`
`DefaultCDOMerger.ResolutionPreference`
Enumerates the possible resolution preferences that can be used with a `DefaultCDOMerger`.

## Nested classes/interfaces inherited from interface org.eclipse.emf.cdo.transaction.CDOMerger

`CDOMerger.ConflictException`

## Constructor Summary

Constructors
Constructor
Description
`DefaultCDOMerger()`
`DefaultCDOMerger(CDOCommonRepository.ListOrdering listOrdering)`
`DefaultCDOMerger(DefaultCDOMerger.ResolutionPreference resolutionPreference)`
`DefaultCDOMerger(DefaultCDOMerger.ResolutionPreference resolutionPreference, CDOCommonRepository.ListOrdering listOrdering)`

## Method Summary

Modifier and Type
Method
Description
`protected Object`
`addedInSource(CDORevision revision)`
`protected Object`
`addedInSourceAndTarget(CDORevision targetRevision, CDORevision sourceRevision)`
`protected Object`
`addedInTarget(CDORevision revision)`
`protected Object`
`changedInSource(CDORevisionDelta delta)`
`protected Object`
`changedInSource(CDORevisionDelta delta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision, CDORevision sourceEndRevision)`
Resolves a one-sided source change as a goal relative to the actual result base.
`protected Object`
`changedInSourceAndDetachedInTarget(CDORevisionDelta sourceDelta)`
`protected Object`
`changedInSourceAndDetachedInTarget(CDORevisionDelta sourceDelta, CDORevision resultBaseRevision, CDORevision sourceBaseRevision, CDORevision sourceEndRevision)`
Resolves source-change versus target-detach as a result-base-relative goal.
`protected Object`
`changedInSourceAndTarget(CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta)`
`protected Object`
`changedInSourceAndTarget(CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta, CDORevision ancestorRevision)`
Resolves concurrent revision changes with an optional full common-ancestor revision.
`protected Object`
`changedInSourceAndTarget(CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision)`
Resolves concurrent revision changes with explicit asymmetric branch/remerge base revisions.
`protected Object`
`changedInTarget(CDORevisionDelta delta)`
`protected Object`
`changedInTarget(CDORevisionDelta delta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision, CDORevision targetEndRevision)`
Resolves a one-sided target change as a goal relative to the actual result base.
`protected Object`
`changedInTargetAndDetachedInSource(CDORevisionDelta targetDelta)`
`protected Object`
`changedInTargetAndDetachedInSource(CDORevisionDelta targetDelta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision targetEndRevision)`
Resolves target-change versus source-detach as a result-base-relative goal.
`protected Object`
`detachedInSource(CDOID id)`
`protected Object`
`detachedInSourceAndTarget(CDOID id)`
`protected Object`
`detachedInTarget(CDOID id)`
`Map<CDOID,DefaultCDOMerger.Conflict>`
`getConflicts()`
`CDOCommonRepository.ListOrdering`
`getListOrdering()`
`final DefaultCDOMerger.ResolutionPreference`
`getResolutionPreference()`
`CDOChangeSetData`
`getResult()`
`protected Map<CDOID,Object>`
`getSourceMap()`
`protected Map<CDOID,Object>`
`getTargetMap()`
`protected boolean`
`merge(Object targetData, Object sourceData)`
`protected boolean`
`merge(Object targetData, Object sourceData, CDORevision ancestorRevision)`
Merges the data for one object with the full common-ancestor revision when the producing call path retained it.
`protected boolean`
`merge(Object targetData, Object sourceData, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision)`
Merges one object's data with the result, target, and source base revisions needed by asymmetric branch remerge.
`protected boolean`
`merge(Object targetData, Object sourceData, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision, CDORevision targetEndRevision, CDORevision sourceEndRevision)`
Merges one object's data while keeping every returned goal relative to `resultBaseRevision`.
`CDOChangeSetData`
`merge(CDOChangeSet target, CDOChangeSet source)`
Calculates the changes between a source `change set` and a target `change set` and returns the result relative to their common ancestor.
`CDOChangeSetData`
`merge(CDOChangeSet target, CDOChangeSet source, CDORevisionProvider targetBaseProvider, CDORevisionProvider sourceBaseProvider, CDORevisionProvider resultBaseProvider)`
Merges branch/remerge change sets while preserving their independently selected source and target bases.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultCDOMerger

public DefaultCDOMerger()

### DefaultCDOMerger

public DefaultCDOMerger(CDOCommonRepository.ListOrdering listOrdering)

Since:
  4.6

### DefaultCDOMerger

public DefaultCDOMerger(DefaultCDOMerger.ResolutionPreference resolutionPreference)

Since:
  4.2

### DefaultCDOMerger

public DefaultCDOMerger(DefaultCDOMerger.ResolutionPreference resolutionPreference, CDOCommonRepository.ListOrdering listOrdering)

Since:
  4.6

## Method Details

### getResolutionPreference

public final DefaultCDOMerger.ResolutionPreference getResolutionPreference()

Since:
  4.2

### getListOrdering

public CDOCommonRepository.ListOrdering getListOrdering()

Since:
  4.6

### getResult

public CDOChangeSetData getResult()

### getConflicts

public Map<CDOID,DefaultCDOMerger.Conflict> getConflicts()

### merge

public CDOChangeSetData merge(CDOChangeSet target, CDOChangeSet source) throws CDOMerger.ConflictException
Description copied from interface: `CDOMerger`
Calculates the changes between a source `change set` and a target `change set` and returns the result relative to their common ancestor.

Specified by:
  `merge` in interface `CDOMerger`
Throws:
  `CDOMerger.ConflictException`

### merge

public CDOChangeSetData merge(CDOChangeSet target, CDOChangeSet source, CDORevisionProvider targetBaseProvider, CDORevisionProvider sourceBaseProvider, CDORevisionProvider resultBaseProvider) throws CDOMerger.ConflictException
Merges branch/remerge change sets while preserving their independently selected source and target bases.

Automatic remerge can legitimately produce list histories with different origin sizes because each history starts at the base that side actually observed. Reconstructing endpoint snapshots relative to the result base would turn an occurrence that one side never observed into a synthetic REMOVE. Instead the original executable histories are retained and the three base providers are propagated to the semantic many-valued merger.

The ordinary two-argument `merge(CDOChangeSet, CDOChangeSet)` contract is retained for callers whose two change sets already share their merge base.

Specified by:
  `merge` in interface `CDOMergerBaseAware`
Parameters:
  `target` - the target change set selected by the branch merge calculation.
  `source` - the source change set selected by the branch merge calculation.
  `targetBaseProvider` - the revision state from which `target` starts.
  `sourceBaseProvider` - the revision state from which `source` starts.
  `resultBaseProvider` - the revision state relative to which every returned NEW, CHANGED, or DETACHED goal is defined.
Returns:
  the merged change-set data relative to `resultBaseProvider`.
Throws:
  `CDOMerger.ConflictException` - if the configured merger semantics cannot resolve all conflicts.
Since:
  4.30

### merge

protected boolean merge(Object targetData, Object sourceData)

### merge

protected boolean merge(Object targetData, Object sourceData, CDORevision ancestorRevision)
Merges the data for one object with the full common-ancestor revision when the producing call path retained it. The extra revision is an internal execution context; it does not widen the public `CDOMerger` contract.

Since:
  4.30

### merge

protected boolean merge(Object targetData, Object sourceData, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision)
Merges one object's data with the result, target, and source base revisions needed by asymmetric branch remerge. Existing extenders remain on the common-ancestor overload unless they explicitly consume the richer context.

Since:
  4.30

### merge

protected boolean merge(Object targetData, Object sourceData, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision, CDORevision targetEndRevision, CDORevision sourceEndRevision)
Merges one object's data while keeping every returned goal relative to `resultBaseRevision`. NEW and DETACHED classifications are first normalized to that base. CHANGED histories keep their own causal bases so semantic list merging does not lose unobserved-occurrence information.

Since:
  4.30

### addedInTarget

protected Object addedInTarget(CDORevision revision)

### addedInSource

protected Object addedInSource(CDORevision revision)

### addedInSourceAndTarget

protected Object addedInSourceAndTarget(CDORevision targetRevision, CDORevision sourceRevision)

### changedInTarget

protected Object changedInTarget(CDORevisionDelta delta)

### detachedInTarget

protected Object detachedInTarget(CDOID id)

### changedInTarget

protected Object changedInTarget(CDORevisionDelta delta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision, CDORevision targetEndRevision)
Resolves a one-sided target change as a goal relative to the actual result base.

The base implementation treats the selected target endpoint as the complete object-level goal. `DefaultCDOMerger.PerFeature` refines this behavior so unchanged features stay unobserved and many-valued changes retain occurrence semantics.

Since:
  4.30

### changedInSource

protected Object changedInSource(CDORevisionDelta delta)

### changedInSource

protected Object changedInSource(CDORevisionDelta delta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision, CDORevision sourceEndRevision)
Resolves a one-sided source change as a goal relative to the actual result base.

The base implementation treats the selected source endpoint as the complete object-level goal. `DefaultCDOMerger.PerFeature` refines this behavior so unchanged features stay unobserved and many-valued changes retain occurrence semantics.

Since:
  4.30

### detachedInSource

protected Object detachedInSource(CDOID id)

### detachedInSourceAndTarget

protected Object detachedInSourceAndTarget(CDOID id)

### changedInSourceAndTarget

protected Object changedInSourceAndTarget(CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta)

### changedInSourceAndTarget

protected Object changedInSourceAndTarget(CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta, CDORevision ancestorRevision)
Resolves concurrent revision changes with an optional full common-ancestor revision. Subclasses that need only deltas retain the established two-argument hook; semantic many-valued merging overrides this overload.

Since:
  4.30

### changedInSourceAndTarget

protected Object changedInSourceAndTarget(CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision sourceBaseRevision)
Resolves concurrent revision changes with explicit asymmetric branch/remerge base revisions.

Since:
  4.30

### changedInSourceAndDetachedInTarget

protected Object changedInSourceAndDetachedInTarget(CDORevisionDelta sourceDelta)

### changedInTargetAndDetachedInSource

protected Object changedInTargetAndDetachedInSource(CDORevisionDelta targetDelta)

### changedInSourceAndDetachedInTarget

protected Object changedInSourceAndDetachedInTarget(CDORevisionDelta sourceDelta, CDORevision resultBaseRevision, CDORevision sourceBaseRevision, CDORevision sourceEndRevision)
Resolves source-change versus target-detach as a result-base-relative goal.

Since:
  4.30

### changedInTargetAndDetachedInSource

protected Object changedInTargetAndDetachedInSource(CDORevisionDelta targetDelta, CDORevision resultBaseRevision, CDORevision targetBaseRevision, CDORevision targetEndRevision)
Resolves target-change versus source-detach as a result-base-relative goal.

Since:
  4.30

### getTargetMap

protected Map<CDOID,Object> getTargetMap()

### getSourceMap

protected Map<CDOID,Object> getSourceMap()