org.apache.sling.provisioning.model

## Class ModelUtility

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

    public abstract class ModelUtility
    extends Object

Model utility

### Nested Class Summary

Nested Classes
`static interface` `ModelUtility.ArtifactVersionResolver` Optional artifact dependency version resolver
`static class` `ModelUtility.ResolverOptions` Parameter builder class for `getEffectiveModel(Model, ResolverOptions)` method.
`static interface` `ModelUtility.VariableResolver` Optional variable resolver

### Constructor Summary

Constructors
Constructor and Description
`ModelUtility()`

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static Model` `applyArtifactVersions(Model model, ModelUtility.ArtifactVersionResolver resolver)` Resolves artifact versions that are no set explicitly in the provisioning file via the given resolver (version = "LATEST").
`static Model` `applyVariables(Model model, ModelUtility.VariableResolver resolver)` Applies a set of variables to the given model.
`static Model` `getEffectiveModel(Model model)` Replace all variables in the model and return a new model with the replaced values.
`static Model` `getEffectiveModel(Model model, ModelUtility.ResolverOptions options)` Replace all variables in the model and return a new model with the replaced values.
`static Model` `getEffectiveModel(Model model, ModelUtility.VariableResolver resolver)` Deprecated. Use `getEffectiveModel(Model)` or `getEffectiveModel(Model, ResolverOptions)` instead
`static void` `merge(Model base, Model additional)` Deprecated. Use {link `MergeUtility.merge(Model, Model)`
`static void` `merge(Model base, Model additional, boolean handleRemove)` Deprecated. Use {link `MergeUtility.merge(Model, Model, org.apache.sling.provisioning.model.MergeUtility.MergeOptions)`
`static Map<Traceable,String>` `validate(Model model)` Validates the model.
`static Map<Traceable,String>` `validateIncludingVersion(Model model)` Validates the model and checks that each feature has a valid version.

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

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

### Constructor Detail

#### ModelUtility

    public ModelUtility()

### Method Detail

#### merge

    @Deprecated
    public static void merge(Model base,
                                         Model additional)

Deprecated. Use {link `MergeUtility.merge(Model, Model)`
Merge the additional model into the base model.

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

#### merge

    @Deprecated
    public static void merge(Model base,
                                         Model additional,
                                         boolean handleRemove)

Deprecated. Use {link `MergeUtility.merge(Model, Model, org.apache.sling.provisioning.model.MergeUtility.MergeOptions)`
Merge the additional model into the base model.

Parameters:
  `base` - The base model.
  `additional` - The additional model.
  `handleRemove` - Handle special remove run mode
Since:
  1.2

#### getEffectiveModel

    @Deprecated
    public static Model getEffectiveModel(Model model,
                                                      ModelUtility.VariableResolver resolver)

Deprecated. Use `getEffectiveModel(Model)` or `getEffectiveModel(Model, ResolverOptions)` instead
Replace all variables in the model and return a new model with the replaced values.

Parameters:
  `model` - The base model.
  `resolver` - Optional variable resolver.
Returns:
  The model with replaced variables.
Throws:
  `IllegalArgumentException` - If a variable can't be replaced or configuration properties can't be parsed

#### getEffectiveModel

    public static Model getEffectiveModel(Model model)

Replace all variables in the model and return a new model with the replaced values.

Parameters:
  `model` - The base model.
Returns:
  The model with replaced variables.
Throws:
  `IllegalArgumentException` - If a variable can't be replaced or configuration properties can't be parsed
Since:
  1.3

#### getEffectiveModel

    public static Model getEffectiveModel(Model model,
                                          ModelUtility.ResolverOptions options)

Replace all variables in the model and return a new model with the replaced values.

Parameters:
  `model` - The base model.
  `options` - Resolver options.
Returns:
  The model with replaced variables.
Throws:
  `IllegalArgumentException` - If a variable can't be replaced or configuration properties can't be parsed
Since:
  1.3

#### validate

    public static Map<Traceable,String> validate(Model model)

Validates the model.

Parameters:
  `model` - The model to validate
Returns:
  A map with errors or `null` if valid.

#### applyVariables

    public static Model applyVariables(Model model,
                                       ModelUtility.VariableResolver resolver)

Applies a set of variables to the given model. All variables that are referenced anywhere within the model are detected and passed to the given variable resolver. The variable resolver may look up variables on it's own, or fall back to the variables already defined for the feature. All resolved variable values are collected and put to the "variables" section of the resulting model.

Parameters:
  `model` - Original model
  `resolver` - Variable resolver
Returns:
  Model with updated "variables" section.
Throws:
  `IllegalArgumentException` - If a variable can't be replaced or configuration properties can't be parsed
Since:
  1.3

#### applyArtifactVersions

    public static Model applyArtifactVersions(Model model,
                                              ModelUtility.ArtifactVersionResolver resolver)

Resolves artifact versions that are no set explicitly in the provisioning file via the given resolver (version = "LATEST"). If the resolver does not resolve to a version "LATEST" is left in the model. The resolver may decide to raise an IllegalArgumentException in this case if unresolved dependencies are no allowed.

Parameters:
  `model` - Original model
  `resolver` - Artifact version resolver
Returns:
  Model with updated artifact versions
Throws:
  `IllegalArgumentException` - If the provider does not allow unresolved version and a version could not be resolved
Since:
  1.3

#### validateIncludingVersion

    public static Map<Traceable,String> validateIncludingVersion(Model model)

Validates the model and checks that each feature has a valid version. This method first calls `validate(Model)` and then checks that each feature has a version.

Parameters:
  `model` - The model to validate
Returns:
  A map with errors or `null` if valid.
Since:
  1.9