Class ModelUtility


  • public abstract class ModelUtility
    extends java.lang.Object
    Model utility
    • Constructor Detail

      • ModelUtility

        public ModelUtility()
    • Method Detail

      • merge

        @Deprecated
        public static void merge​(Model base,
                                 Model additional)
        Deprecated.
        Merge the additional model into the base model.
        Parameters:
        base - The base model.
        additional - The additional model.
      • getEffectiveModel

        @Deprecated
        public static Model getEffectiveModel​(Model model,
                                              ModelUtility.VariableResolver resolver)
        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:
        java.lang.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:
        java.lang.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:
        java.lang.IllegalArgumentException - If a variable can't be replaced or configuration properties can't be parsed
        Since:
        1.3
      • validate

        public static java.util.Map<Traceable,​java.lang.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:
        java.lang.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:
        java.lang.IllegalArgumentException - If the provider does not allow unresolved version and a version could not be resolved
        Since:
        1.3
      • validateIncludingVersion

        public static java.util.Map<Traceable,​java.lang.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