com.redhat.ceylon.common.tool.MapToolLoader Maven / Gradle / Ivy
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 extends Tool>... classes) {
MapToolLoader result = new MapToolLoader();
for (Class extends Tool> 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