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

io.github.mivek.command.metar.MetarParserCommandSupplier Maven / Gradle / Ivy

package io.github.mivek.command.metar;

import io.github.mivek.command.Supplier;

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

/**
 * @author mivek
 */
public final class MetarParserCommandSupplier implements Supplier {
    /** List of command for the metarParser. */
    private final List commands;

    /**
     * Constructor.
     */
    public MetarParserCommandSupplier() {
        commands = buildCommandList();
    }

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

    /**
     * @return The list of commands used by this parser.
     */
    protected List buildCommandList() {
        List commandList = new ArrayList<>();
        commandList.add(new RunwayCommand());
        commandList.add(new TemperatureCommand());
        commandList.add(new AltimeterCommand());
        commandList.add(new AltimeterMecuryCommand());

        return commandList;
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy