@Test public void testAbsentUrlReturnsAbsentHash() throws Exception { Assert.assertFalse("absent url results in absent hash", hashFileGenerator.hash(Optional.<URL>absent()).isPresent()); }
@Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); }
MD5HashFileGenerator implements HashFileGenerator, InitializingBean { @Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); } }
MD5HashFileGenerator implements HashFileGenerator, InitializingBean { @Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); }  }
MD5HashFileGenerator implements HashFileGenerator, InitializingBean { @Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); }  void afterPropertiesSet(); @Override Optional<String> hash(final Optional<URL> url); @Override Optional<String> hashMulti(final Collection<URL> urls); static String getMD5Checksum(final InputStream is); void setHotReloadMode(boolean hotReloadMode); void setCacheMaxSize(int cacheMaxSize); void setExpireAfterWrite(int expireAfterWrite); void setExpireAfterWriteUnit(String expireAfterWriteUnit); boolean isHotReloadMode(); int getCacheMaxSize(); int getExpireAfterWrite(); String getExpireAfterWriteUnit(); }
MD5HashFileGenerator implements HashFileGenerator, InitializingBean { @Override public Optional<String> hash(final Optional<URL> url) throws IOException { if (!url.isPresent()) { return Optional.absent(); } logger.debug("Calculating md5 hash, url:{}", url); if (isHotReloadModeOff()) { final String md5 = cache.getIfPresent(url.get()); logger.debug("md5 hash:{}", md5); if (md5 != null) { return Optional.of(md5); } } final InputStream is = url.get().openStream(); final String md5 = getMD5Checksum(is); if (isHotReloadModeOff()) { logger.debug("caching url:{} with hash:{}", url, md5); cache.put(url.get(), md5); } return Optional.fromNullable(md5); }  void afterPropertiesSet(); @Override Optional<String> hash(final Optional<URL> url); @Override Optional<String> hashMulti(final Collection<URL> urls); static String getMD5Checksum(final InputStream is); void setHotReloadMode(boolean hotReloadMode); void setCacheMaxSize(int cacheMaxSize); void setExpireAfterWrite(int expireAfterWrite); void setExpireAfterWriteUnit(String expireAfterWriteUnit); boolean isHotReloadMode(); int getCacheMaxSize(); int getExpireAfterWrite(); String getExpireAfterWriteUnit();  }