@Test public void testLastModified() throws Exception { final File file = getFile(FileConfigFileLoaderTest.class, "config.yaml"); Optional<Long> lastModified = this.loader.lastModified(new URI(configFileUriString)); assertTrue(lastModified.isPresent()); assertEquals(file.lastModified(), lastModified.get().longValue()); }
@Override public Optional<Long> lastModified(final URI fileURI) { final Optional<URL> resources = loadResources(fileURI); if (resources.isPresent()) { final URL url = resources.get(); if (url.getProtocol().equalsIgnoreCase(FileConfigFileLoader.PREFIX)) { try { return Optional.of(new File(url.toURI()).lastModified()); } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } } else { return Optional.empty(); } } throw new NoSuchElementException(fileURI + " does not exist"); }
ClasspathConfigFileLoader implements ConfigFileLoaderPlugin { @Override public Optional<Long> lastModified(final URI fileURI) { final Optional<URL> resources = loadResources(fileURI); if (resources.isPresent()) { final URL url = resources.get(); if (url.getProtocol().equalsIgnoreCase(FileConfigFileLoader.PREFIX)) { try { return Optional.of(new File(url.toURI()).lastModified()); } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } } else { return Optional.empty(); } } throw new NoSuchElementException(fileURI + " does not exist"); } }
ClasspathConfigFileLoader implements ConfigFileLoaderPlugin { @Override public Optional<Long> lastModified(final URI fileURI) { final Optional<URL> resources = loadResources(fileURI); if (resources.isPresent()) { final URL url = resources.get(); if (url.getProtocol().equalsIgnoreCase(FileConfigFileLoader.PREFIX)) { try { return Optional.of(new File(url.toURI()).lastModified()); } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } } else { return Optional.empty(); } } throw new NoSuchElementException(fileURI + " does not exist"); }  }
ClasspathConfigFileLoader implements ConfigFileLoaderPlugin { @Override public Optional<Long> lastModified(final URI fileURI) { final Optional<URL> resources = loadResources(fileURI); if (resources.isPresent()) { final URL url = resources.get(); if (url.getProtocol().equalsIgnoreCase(FileConfigFileLoader.PREFIX)) { try { return Optional.of(new File(url.toURI()).lastModified()); } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } } else { return Optional.empty(); } } throw new NoSuchElementException(fileURI + " does not exist"); }  @Override Optional<File> toFile(final URI fileUri); @Override String getUriScheme(); @Override Optional<Long> lastModified(final URI fileURI); @Override boolean isAccessible(final URI fileURI); @Override byte[] loadFile(final URI fileURI); @Override boolean isAccessible(final URI configFileUri, final String pathToSubResource); @Override byte[] loadFile(final URI configFileUri, final String pathToSubResource); }
ClasspathConfigFileLoader implements ConfigFileLoaderPlugin { @Override public Optional<Long> lastModified(final URI fileURI) { final Optional<URL> resources = loadResources(fileURI); if (resources.isPresent()) { final URL url = resources.get(); if (url.getProtocol().equalsIgnoreCase(FileConfigFileLoader.PREFIX)) { try { return Optional.of(new File(url.toURI()).lastModified()); } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } } else { return Optional.empty(); } } throw new NoSuchElementException(fileURI + " does not exist"); }  @Override Optional<File> toFile(final URI fileUri); @Override String getUriScheme(); @Override Optional<Long> lastModified(final URI fileURI); @Override boolean isAccessible(final URI fileURI); @Override byte[] loadFile(final URI fileURI); @Override boolean isAccessible(final URI configFileUri, final String pathToSubResource); @Override byte[] loadFile(final URI configFileUri, final String pathToSubResource); static final String PREFIX; static final int PREFIX_LENGTH; }