@Test public void test() throws IOException { final UpdateMonitor lastModified = new LastModifiedMonitor(); final MD5SumMonitor md5 = new MD5SumMonitor(); final CompoundUpdateMonitor compound = new CompoundUpdateMonitor(lastModified, md5); final File file = new File("target/" + UUID.randomUUID().toString()); if (file.exists()) { assertTrue(file.delete()); } assertTrue(file.createNewFile()); final Path path = file.toPath(); final Object curState = compound.getCurrentState(path); final Object state2 = compound.getCurrentState(path); assertEquals(curState, state2); file.setLastModified(System.currentTimeMillis() + 1000L); final Object state3 = compound.getCurrentState(path); assertEquals(state2, state3); final Object state4 = compound.getCurrentState(path); assertEquals(state3, state4); final long lastModifiedDate = file.lastModified(); try (final OutputStream out = new FileOutputStream(file)) { out.write("Hello".getBytes("UTF-8")); } file.setLastModified(lastModifiedDate); final Object state5 = compound.getCurrentState(path); assertNotSame(state4, state5); }
@Override public Object getCurrentState(final Path path) throws IOException { return new DeferredMonitorAction(monitors, path); }
CompoundUpdateMonitor implements UpdateMonitor { @Override public Object getCurrentState(final Path path) throws IOException { return new DeferredMonitorAction(monitors, path); } }
CompoundUpdateMonitor implements UpdateMonitor { @Override public Object getCurrentState(final Path path) throws IOException { return new DeferredMonitorAction(monitors, path); } CompoundUpdateMonitor(final UpdateMonitor first, final UpdateMonitor... others); }
CompoundUpdateMonitor implements UpdateMonitor { @Override public Object getCurrentState(final Path path) throws IOException { return new DeferredMonitorAction(monitors, path); } CompoundUpdateMonitor(final UpdateMonitor first, final UpdateMonitor... others); @Override Object getCurrentState(final Path path); }
CompoundUpdateMonitor implements UpdateMonitor { @Override public Object getCurrentState(final Path path) throws IOException { return new DeferredMonitorAction(monitors, path); } CompoundUpdateMonitor(final UpdateMonitor first, final UpdateMonitor... others); @Override Object getCurrentState(final Path path);  }