All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.airlift.command.model.CommandGroupMetadata Maven / Gradle / Ivy

Go to download

Airline is a Java annotation-based framework for parsing Git like command line structures.

The newest version!
package io.airlift.command.model;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

import java.util.List;

public class CommandGroupMetadata
{
    private final String name;
    private final String description;
    private final List options;
    private final CommandMetadata defaultCommand;
    private final List commands;

    public CommandGroupMetadata(String name, String description, Iterable options, CommandMetadata defaultCommand, Iterable commands)
    {
        this.name = name;
        this.description = description;
        this.options = ImmutableList.copyOf(options);
        this.defaultCommand = defaultCommand;
        this.commands = Lists.newArrayList(commands);
    }

    public String getName()
    {
        return name;
    }

    public String getDescription()
    {
        return description;
    }

    public List getOptions()
    {
        return options;
    }

    public CommandMetadata getDefaultCommand()
    {
        return defaultCommand;
    }

    public List getCommands()
    {
        return ImmutableList.copyOf(commands);
    }
    
    public void addCommand(CommandMetadata command)
    {
        if(!commands.contains(command))
        {
            commands.add(command);
        }
    }

    @Override
    public String toString()
    {
        final StringBuilder sb = new StringBuilder();
        sb.append("CommandGroupMetadata");
        sb.append("{name='").append(name).append('\'');
        sb.append(", description='").append(description).append('\'');
        sb.append(", options=").append(options);
        sb.append(", defaultCommand=").append(defaultCommand);
        sb.append(", commands=").append(commands);
        sb.append('}');
        return sb.toString();
    }

    public static Function nameGetter()
    {
        return new Function()
        {
            public String apply(CommandGroupMetadata input)
            {
                return input.getName();
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy