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

com.redhat.ceylon.common.tool.ToolArgumentParser Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
package com.redhat.ceylon.common.tool;


/**
 * An {@link ArgumentParser} for {@link Tool}s. This is used for subtools
 * @author tom
 */
public class ToolArgumentParser implements EnumerableParser{

    private ToolLoader loader;

    protected ToolArgumentParser(ToolLoader loader) {
        this.loader = loader;
    }
    
    ToolLoader getToolLoader() {
        return loader;
    }

    @Override
    public Tool parse(final String argument, Tool tool) {
        Tool instance = loader.instance(argument, tool);
        if (instance == null) {
            throw new IllegalArgumentException(argument);
        }
        return instance;
    }

    @Override
    public Iterable possibilities() {
        return loader.getToolNames();
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy