ObjectHeader { public static LazyInitializer<ObjectHeader> lazyReadObjectHeader(HdfFileChannel hdfFc, long address) { logger.debug("Creating lazy object header at address: {}", address); return new LazyInitializer<ObjectHeader>() { @Override protected ObjectHeader initialize() { logger.debug("Lazy initializing object header at address: {}", address); return readObjectHeader(hdfFc, address); } }; } ObjectHeader(long address); long getAddress(); abstract int getVersion(); abstract boolean isAttributeCreationOrderTracked(); abstract boolean isAttributeCreationOrderIndexed(); List<Message> getMessages(); List<T> getMessagesOfType(Class<T> type); boolean hasMessageOfType(Class<T> type); T getMessageOfType(Class<T> type); static ObjectHeader readObjectHeader(HdfFileChannel hdfFc, long address); static LazyInitializer<ObjectHeader> lazyReadObjectHeader(HdfFileChannel hdfFc, long address);  }
@Test void testLazyObjectHeader() throws ConcurrentException, IOException { FileChannel spyFc = Mockito.spy(fc); HdfFileChannel hdfFileChannel = new HdfFileChannel(spyFc, sb); LazyInitializer<ObjectHeader> lazyObjectHeader = ObjectHeader.lazyReadObjectHeader(hdfFileChannel, 10904); Mockito.verifyNoInteractions(spyFc); lazyObjectHeader.get(); verify(spyFc, Mockito.atLeastOnce()).read(any(ByteBuffer.class), anyLong()); Mockito.verifyNoMoreInteractions(spyFc); }