001package org.apache.maven.lifecycle.mapping;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Collections;
023import java.util.LinkedHashMap;
024import java.util.List;
025import java.util.Map;
026
027
028/**
029 * Class Lifecycle.
030 */
031public class Lifecycle
032{
033    /**
034     * Field id
035     */
036    private String id;
037
038    /**
039     * Field phases
040     */
041    private Map<String, LifecyclePhase> lifecyclePhases;
042
043    /*
044     * NOTE: This exists merely for backward-compat with legacy-style lifecycle definitions and allows configuration
045     * injection to work instead of failing.
046     */
047    @SuppressWarnings( "unused" )
048    private List<String> optionalMojos;
049
050    /**
051     * Method getId
052     */
053    public String getId()
054    {
055        return this.id;
056    }
057
058    /**
059     * Method getLifecyclePhases
060     */
061    public Map<String, LifecyclePhase> getLifecyclePhases()
062    {
063        return this.lifecyclePhases;
064    }
065    
066    /**
067     * Method setId
068     *
069     * @param id
070     */
071    public void setId( String id )
072    {
073        this.id = id;
074    }
075
076    /**
077     * Method setLifecyclePhases
078     *
079     * @param phases
080     */
081    public void setLifecyclePhases( Map<String, LifecyclePhase> lifecyclePhases )
082    {
083        this.lifecyclePhases = lifecyclePhases;
084    }
085
086    @Deprecated
087    public Map<String, String> getPhases()
088    {
089        Map<String, LifecyclePhase> lphases = getLifecyclePhases();
090        if ( lphases == null )
091        {
092            return null;
093        }
094        
095        if ( lphases.isEmpty() )
096        {
097            return Collections.emptyMap();
098        }
099        
100        Map<String, String> phases = new LinkedHashMap<>();
101        for ( Map.Entry<String, LifecyclePhase> e: lphases.entrySet() )
102        {
103            phases.put( e.getKey(), e.getValue().toString() );
104        }
105        return phases;
106    }
107
108    @Deprecated
109    public void setPhases( Map<String, LifecyclePhase> phases )
110    {
111        setLifecyclePhases( phases );
112    }
113}