View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.settings;
20  
21  import org.apache.maven.internal.impl.SettingsUtilsV4;
22  
23  /**
24   * Several convenience methods to handle settings
25   *
26   */
27  public final class SettingsUtils {
28  
29      private SettingsUtils() {
30          // don't allow construction.
31      }
32  
33      /**
34       * @param dominant
35       * @param recessive
36       * @param recessiveSourceLevel
37       */
38      public static void merge(Settings dominant, Settings recessive, String recessiveSourceLevel) {
39          if (dominant != null && recessive != null) {
40              dominant.delegate = SettingsUtilsV4.merge(dominant.getDelegate(), recessive.getDelegate());
41          }
42      }
43  
44      /**
45       * @param modelProfile
46       * @return a profile
47       */
48      public static Profile convertToSettingsProfile(org.apache.maven.model.Profile modelProfile) {
49          return new Profile(SettingsUtilsV4.convertToSettingsProfile(modelProfile.getDelegate()));
50      }
51  
52      /**
53       * @param settingsProfile
54       * @return a profile
55       */
56      public static org.apache.maven.model.Profile convertFromSettingsProfile(Profile settingsProfile) {
57          return new org.apache.maven.model.Profile(
58                  SettingsUtilsV4.convertFromSettingsProfile(settingsProfile.getDelegate()));
59      }
60  
61      /**
62       * @param settings could be null
63       * @return a new instance of settings or null if settings was null.
64       */
65      public static Settings copySettings(Settings settings) {
66          if (settings == null) {
67              return null;
68          }
69  
70          return new Settings(settings.getDelegate());
71      }
72  }