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

io.github.mivek.command.common.CommonCommandSupplier Maven / Gradle / Ivy

package io.github.mivek.command.common;

import io.github.mivek.command.Supplier;

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

/**
 * @author mivek
 */
public final class CommonCommandSupplier implements Supplier {
    /** The list of commands. */
    private final List commands;

    /**
     * Default constructor.
     */
    public CommonCommandSupplier() {
        commands = buildCommands();
    }

    @Override public Command get(final String pString) {
        for (Command command : commands) {
            if (command.canParse(pString)) {
                return command;
            }
        }
        return null;
    }

    /**
     * Builds list of commands.
     *
     * @return the list of commands.
     */
    protected List buildCommands() {
        List commandList = new ArrayList<>();
        commandList.add(new WindShearCommand());
        commandList.add(new WindCommand());
        commandList.add(new WindExtremeCommand());
        commandList.add(new MainVisibilityCommand());
        commandList.add(new MainVisibilityNauticalMilesCommand());
        commandList.add(new MinimalVisibilityCommand());
        commandList.add(new VerticalVisibilityCommand());
        commandList.add(new CloudCommand());
        return commandList;
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy