001package org.apache.maven.lifecycle.internal;
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.ArrayList;
023import java.util.Arrays;
024import java.util.List;
025
026/**
027 * Describes the required task segment as provided on the maven command line; i.e. "clean jetty:run install"
028 * 
029 * @since 3.0
030 * @author Benjamin Bentmann
031 * @author Kristian Rosenvold (extracted class only)
032 *         <p/>
033 *         NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
034 */
035public final class TaskSegment
036{
037
038    // Can be both "LifeCycleTask" (clean/install) and "GoalTask" (org.mortbay.jetty:maven-jetty-plugin:6.1.19:run)
039
040    private final List<Object> tasks;
041
042    private final boolean aggregating;
043
044    public TaskSegment( boolean aggregating )
045    {
046        this.aggregating = aggregating;
047        tasks = new ArrayList<Object>();
048    }
049
050    public TaskSegment( boolean aggregating, Object... tasks )
051    {
052        this.aggregating = aggregating;
053        this.tasks = new ArrayList<Object>( Arrays.asList( tasks ) );
054    }
055
056    @Override
057    public String toString()
058    {
059        return getTasks().toString();
060    }
061
062    public List<Object> getTasks()
063    {
064        return tasks;
065    }
066
067    public boolean isAggregating()
068    {
069        return aggregating;
070    }
071
072    // TODO: Consider throwing UnsupprtedSomething on hashCode/equals
073}