@Test public void convertNull() throws Exception { PathConverter conv = new PathConverter(); Path value = conv.convert(null, context); assertThat(value).isNull(); value = conv.convert("", context); assertThat(value).isNull(); }
@Override public Path convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(),"<File>"); if(value==null){ return null; } String trimmed = value.trim(); if(value.isEmpty()){ return null; } try { return FileSystems.getDefault().getPath(value); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable Path: " + trimmed, e); return null; } }
PathConverter implements PropertyConverter<Path> { @Override public Path convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(),"<File>"); if(value==null){ return null; } String trimmed = value.trim(); if(value.isEmpty()){ return null; } try { return FileSystems.getDefault().getPath(value); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable Path: " + trimmed, e); return null; } } }
PathConverter implements PropertyConverter<Path> { @Override public Path convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(),"<File>"); if(value==null){ return null; } String trimmed = value.trim(); if(value.isEmpty()){ return null; } try { return FileSystems.getDefault().getPath(value); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable Path: " + trimmed, e); return null; } }  }
PathConverter implements PropertyConverter<Path> { @Override public Path convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(),"<File>"); if(value==null){ return null; } String trimmed = value.trim(); if(value.isEmpty()){ return null; } try { return FileSystems.getDefault().getPath(value); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable Path: " + trimmed, e); return null; } }  @Override Path convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode(); }
PathConverter implements PropertyConverter<Path> { @Override public Path convert(String value, ConversionContext ctx) { ctx.addSupportedFormats(getClass(),"<File>"); if(value==null){ return null; } String trimmed = value.trim(); if(value.isEmpty()){ return null; } try { return FileSystems.getDefault().getPath(value); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable Path: " + trimmed, e); return null; } }  @Override Path convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode();  }