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

com.redhat.ceylon.common.tool.ToolModelArgumentParser 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 ToolModel}s. This is useful for tools 
 * which operate on other tool's models, such as help tools and tool 
 * documentation generators. 
 * @author tom
 */
public class ToolModelArgumentParser implements EnumerableParser>{

    private ToolLoader loader;

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy