org.apache.sling.provisioning.model

## Class MergeUtility

- java.lang.Object
- - org.apache.sling.provisioning.model.MergeUtility

    public abstract class MergeUtility
    extends Object

Utility for merging two models.

Since:
  1.4

### Nested Class Summary

Nested Classes
`static class` `MergeUtility.MergeOptions` Options for specifying some parts of the merge operation.

### Constructor Summary

Constructors
Constructor and Description
`MergeUtility()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `merge(Model base, Model additional)` Merge the additional model into the base model.
`static void` `merge(Model base, Model additional, MergeUtility.MergeOptions options)` Merge the additional model into the base model.
`static void` `mergeComments(Commentable base, Commentable additional)` Merge the comments

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

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

### Constructor Detail

#### MergeUtility

    public MergeUtility()

### Method Detail

#### merge

    public static void merge(Model base,
                             Model additional)

Merge the additional model into the base model.

Parameters:
  `base` - The base model.
  `additional` - The additional model.

#### merge

    public static void merge(Model base,
                             Model additional,
                             MergeUtility.MergeOptions options)

Merge the additional model into the base model.

Merging is performed feature by feature. Each feature is treated separately. If the base model does not have a feature from the additional model, the complete feature is added. If the base model has a feature which is not in the additional model, the feature is left as is.

For each feature, the following actions are performed:

- If either the base feature or the additional feature has a version, then the one with the higher version is used, the other one is skipped. A missing version is considered the lowest possible version.
- The feature type of the base feature is set to the type of the additional feature.
- All additional sections of the additional feature are added to the base feature.
- All variables from the additional feature are set on the base feature, overriding values if already present.
- Each run mode of the additional feature is merged into the base feature.

Parameters:
  `base` - The base model.
  `additional` - The additional model.
  `options` - The merge options

#### mergeComments

    public static void mergeComments(Commentable base,
                                     Commentable additional)

Merge the comments

Parameters:
  `base` - The base model object
  `additional` - The additional model object
Since:
  1.9.0