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.lifecycle.mapping;
20  
21  import java.util.Collections;
22  import java.util.LinkedHashMap;
23  import java.util.Map;
24  
25  /**
26   * Lifecycle definition for a packaging (multiple packagings share the same lifecycle id = usually "default").
27   */
28  public class Lifecycle {
29      /**
30       * Field id
31       */
32      private String id;
33  
34      /**
35       * Field phases
36       */
37      private Map<String, LifecyclePhase> lifecyclePhases;
38  
39      /**
40       * Method getId
41       */
42      public String getId() {
43          return this.id;
44      }
45  
46      /**
47       * Method getLifecyclePhases
48       */
49      public Map<String, LifecyclePhase> getLifecyclePhases() {
50          return this.lifecyclePhases;
51      }
52  
53      /**
54       * Method setId
55       *
56       * @param id
57       */
58      public void setId(String id) {
59          this.id = id;
60      }
61  
62      /**
63       * Method setLifecyclePhases
64       *
65       * @param lifecyclePhases
66       */
67      public void setLifecyclePhases(Map<String, LifecyclePhase> lifecyclePhases) {
68          this.lifecyclePhases = lifecyclePhases;
69      }
70  
71      @Deprecated
72      public Map<String, String> getPhases() {
73          Map<String, LifecyclePhase> lphases = getLifecyclePhases();
74          if (lphases == null) {
75              return null;
76          }
77  
78          if (lphases.isEmpty()) {
79              return Collections.emptyMap();
80          }
81  
82          Map<String, String> phases = new LinkedHashMap<>();
83          for (Map.Entry<String, LifecyclePhase> e : lphases.entrySet()) {
84              phases.put(e.getKey(), e.getValue().toString());
85          }
86          return phases;
87      }
88  
89      @Deprecated
90      public void setPhases(Map<String, String> phases) {
91          Map<String, LifecyclePhase> lphases = new LinkedHashMap<>();
92          for (Map.Entry<String, String> e : phases.entrySet()) {
93              lphases.put(e.getKey(), new LifecyclePhase(e.getValue()));
94          }
95          setLifecyclePhases(lphases);
96      }
97  }