| 1 |
package morfologik.tools; |
| 2 |
|
| 3 |
import java.nio.file.Path; |
| 4 |
import java.nio.file.Paths; |
| 5 |
|
| 6 |
import com.beust.jcommander.IStringConverter; |
| 7 |
import com.beust.jcommander.IStringConverterFactory; |
| 8 |
|
| 9 |
class CustomParameterConverters implements IStringConverterFactory { |
| 10 |
public static class PathConverter implements IStringConverter<Path> { |
| 11 |
@Override |
| 12 |
public Path convert(String value) { |
| 13 |
return Paths.get(value); |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
@SuppressWarnings({ "unchecked", "rawtypes" }) |
| 18 |
@Override |
| 19 |
public <T> Class<? extends IStringConverter<T>> getConverter(Class<T> forType) { |
| 20 |
if (forType.equals(Path.class)) { |
| 21 |
return (Class) PathConverter.class; |
| 22 |
} |
| 23 |
return null; |
| 24 |
} |
| 25 |
} |