<commit_before>package io.subutai.common.task;


import java.util.ArrayList;
import java.util.List;

import io.subutai.common.util.JsonUtil;


/**
 * Commands batch
 */
public class CommandBatch
{
    List<Command> commands = new ArrayList<>();


    public void addCommand( Command comm )
    {
        commands.add( comm );
    }


    public String asJson()
    {
        return JsonUtil.toJson( commands );
    }


    public String asChain()
    {
        StringBuilder sb = new StringBuilder();
        for ( Command command : commands )
        {
            sb.append( "&& subutai " + command.getName() );
            for ( String arg : command.getArguments() )
            {
                sb.append( " " + arg );
            }
        }
        return sb.toString().substring( 3 );
    }
}<commit_msg>added command types to CommandBatch class<commit_after>package io.subutai.common.task;


import java.util.ArrayList;
import java.util.List;

import io.subutai.common.util.JsonUtil;


/**
 * Commands batch
 */
public class CommandBatch
{
    enum Type
    {
        STANDARD, CHAIN, JSON;
    }


    private Type type;


    List<Command> commands = new ArrayList<>();


    public CommandBatch( final Type type )
    {
        this.type = type;
    }


    public CommandBatch( final Command command )
    {
        this.type = Type.STANDARD;
        commands.add( command );
    }


    public void addCommand( Command comm )
    {
        if ( this.type == Type.STANDARD && commands.size() > 0 )
        {
            throw new IllegalArgumentException( "Standrad command already contain command." );
        }

        commands.add( comm );
    }


    @Override
    public String toString()
    {
        if ( commands.size() < 1 )
        {
            throw new IllegalStateException( "There is no command in command batch." );
        }

        if ( type == Type.JSON )
        {
            return JsonUtil.toJson( commands );
        }
        else
        {
            return asChain();
        }
    }


    private String asChain()
    {
        StringBuilder sb = new StringBuilder();
        for ( Command command : commands )
        {
            sb.append( "&& subutai " + command.getName() );
            for ( String arg : command.getArguments() )
            {
                sb.append( " " + arg );
            }
        }
        return sb.toString().substring( 3 );
    }
}
{'fraction_non_alphanumeric': 0.11028192371475953, 'fraction_numerical': 0.001658374792703151, 'mean_word_length': 1.7112359550561798, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6444319', 'n_tokens_mistral': 688, 'n_tokens_neox': 654, 'n_words': 168}