Skip to content

Commit

Permalink
Merge pull request cbeust#287 from JesusFreke/master
Browse files Browse the repository at this point in the history
Skip Path converter when class is not available
  • Loading branch information
cbeust authored Sep 19, 2016
2 parents cbdd1cd + a047e47 commit 062c4ae
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.beust.jcommander.converters.URLConverter;

import java.io.File;
import java.lang.NoClassDefFoundError;
import java.math.BigDecimal;
import java.util.Date;
import java.net.URI;
Expand Down Expand Up @@ -63,9 +64,14 @@ public class DefaultConverterFactory implements IStringConverterFactory {
m_classConverters.put(File.class, FileConverter.class);
m_classConverters.put(BigDecimal.class, BigDecimalConverter.class);
m_classConverters.put(Date.class, ISO8601DateConverter.class);
m_classConverters.put(Path.class, PathConverter.class);
m_classConverters.put(URI.class, URIConverter.class);
m_classConverters.put(URL.class, URLConverter.class);

try {
m_classConverters.put(Path.class, PathConverter.class);
} catch (NoClassDefFoundError ex) {
// skip if class is not present (e.g. on Android)
}
}

public Class<? extends IStringConverter<?>> getConverter(Class forType) {
Expand Down

0 comments on commit 062c4ae

Please sign in to comment.