### Question:
Suppliers { public static <T, V> Supplier<T> adapted( final Supplier<V> supplier, final Function<V,T> adaptor ) { return new Supplier<T>() { volatile V lastValue; T instance; @Override public T get() { V value = supplier.get(); if ( value == lastValue ) { return instance; } T adaptedValue = adaptor.apply( value ); synchronized ( this ) { if ( value != lastValue ) { instance = adaptedValue; lastValue = value; } } return instance; } }; } private  Suppliers(); static Supplier<T> singleton( final T instance ); static Lazy<T> lazySingleton( final Supplier<T> supplier ); static Supplier<T> adapted( final Supplier<V> supplier, final Function<V,T> adaptor ); static ThrowingCapturingSupplier<T,E> compose(
            final ThrowingSupplier<T,? extends E> input,
            final ThrowingPredicate<T,? extends E> predicate ); static BooleanSupplier untilTimeExpired( long duration, TimeUnit unit );  }### Answer:
@Test void adaptedSupplierShouldOnlyCallAdaptorOnceForEachNewInstance() { Object o1 = new Object(); Object o1a = new Object(); Object o2 = new Object(); Object o2a = new Object(); Object o3 = new Object(); Object o3a = new Object(); Supplier<Object> mockSupplier = mock( Supplier.class ); when( mockSupplier.get() ).thenReturn( o1, o1, o1, o2, o3, o3 ); Function<Object,Object> mockFunction = mock( Function.class ); when( mockFunction.apply( o1 ) ).thenReturn( o1a ); when( mockFunction.apply( o2 ) ).thenReturn( o2a ); when( mockFunction.apply( o3 ) ).thenReturn( o3a ); Supplier<Object> supplier = Suppliers.adapted( mockSupplier, mockFunction ); assertThat( supplier.get(), sameInstance( o1a ) ); assertThat( supplier.get(), sameInstance( o1a ) ); assertThat( supplier.get(), sameInstance( o1a ) ); assertThat( supplier.get(), sameInstance( o2a ) ); assertThat( supplier.get(), sameInstance( o3a ) ); assertThat( supplier.get(), sameInstance( o3a ) ); verify( mockFunction ).apply( o1 ); verify( mockFunction ).apply( o2 ); verify( mockFunction ).apply( o3 ); verifyNoMoreInteractions( mockFunction ); }