in commons-geometry-io-core/src/main/java/org/apache/commons/geometry/io/core/BoundaryIOManager.java [398:423]
public synchronized T requireHandlerByFormatOrFileName(final GeometryFormat fmt, final String fileName) {
T handler = null;
if (fmt != null) {
handler = getByFormat(fmt);
if (handler == null) {
throw new IllegalArgumentException(MessageFormat.format(
"Failed to find handler for format \"{0}\"", fmt.getFormatName()));
}
} else {
final String fileExt = GeometryIOUtils.getFileExtension(fileName);
if (fileExt != null && !fileExt.isEmpty()) {
handler = getByFileExtension(fileExt);
if (handler == null) {
throw new IllegalArgumentException(MessageFormat.format(
"Failed to find handler for file extension \"{0}\"", fileExt));
}
} else {
throw new IllegalArgumentException(
"Failed to find handler: no format specified and no file extension available");
}
}
return handler;
}