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

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

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

import java.util.HashMap;
import java.util.Map;

public class MapToolLoader extends ToolLoader {

    private final Map map;

    private MapToolLoader() {
        this.map = new HashMap<>();
    }
    
    public MapToolLoader(Map, String> map) {
        this();
        for (Map.Entry, String> entry : map.entrySet()) {
            this.map.put(entry.getKey().getName(), entry.getValue());
        }
    }
    
    @SafeVarargs
    public static MapToolLoader fromClassNames(Class... classes) {
        MapToolLoader result = new MapToolLoader();
        for (Class cls : classes) {
            result.map.put(cls.getName(), result.camelCaseToDashes(cls.getSimpleName()));
        }
        return result;
    }

    @Override
    public String getToolName(String className) {
        return map.get(className);
    }

    @Override
    protected Iterable toolClassNames() {
        return map.keySet();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy