@Test public void testConvert() { FileConverter instance = new FileConverter(); File result; assertThat(instance.convert(null, context)).isNull(); URL testfileUrl = getClass().getResource("/testfile.properties"); System.out.println(testfileUrl.toString()); result = instance.convert(testfileUrl.toString(), context); assertThat(result).isNotNull(); assertThat(context.getSupportedFormats()).contains("<File> (FileConverter)"); }
@Override public File convert(String value, ConversionContext ctx) { if(value==null || value.isEmpty()){ return null; } ctx.addSupportedFormats(getClass(),"<File>"); String trimmed = Objects.requireNonNull(value).trim(); try { return new File(trimmed); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable File Name: " + trimmed, e); } return null; }
FileConverter implements PropertyConverter<File> { @Override public File convert(String value, ConversionContext ctx) { if(value==null || value.isEmpty()){ return null; } ctx.addSupportedFormats(getClass(),"<File>"); String trimmed = Objects.requireNonNull(value).trim(); try { return new File(trimmed); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable File Name: " + trimmed, e); } return null; } }
FileConverter implements PropertyConverter<File> { @Override public File convert(String value, ConversionContext ctx) { if(value==null || value.isEmpty()){ return null; } ctx.addSupportedFormats(getClass(),"<File>"); String trimmed = Objects.requireNonNull(value).trim(); try { return new File(trimmed); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable File Name: " + trimmed, e); } return null; }  }
FileConverter implements PropertyConverter<File> { @Override public File convert(String value, ConversionContext ctx) { if(value==null || value.isEmpty()){ return null; } ctx.addSupportedFormats(getClass(),"<File>"); String trimmed = Objects.requireNonNull(value).trim(); try { return new File(trimmed); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable File Name: " + trimmed, e); } return null; }  @Override File convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode(); }
FileConverter implements PropertyConverter<File> { @Override public File convert(String value, ConversionContext ctx) { if(value==null || value.isEmpty()){ return null; } ctx.addSupportedFormats(getClass(),"<File>"); String trimmed = Objects.requireNonNull(value).trim(); try { return new File(trimmed); } catch (Exception e) { LOG.log(Level.FINE, "Unparseable File Name: " + trimmed, e); } return null; }  @Override File convert(String value, ConversionContext ctx); @Override boolean equals(Object o); @Override int hashCode();  }