@Test public void throwsIfMappingFunctionThrows() { when(STRING_SUPPLIER.get()).thenReturn("42!)*()"); assertThatThrownBy(TRANSFORMING_SUPPLIER::get).isInstanceOf(NumberFormatException.class); }
@Override public synchronized U get() { T currentInput = inputSupplier.get(); if (Objects.equals(cachedInput, currentInput)) { return cachedOutput; } cachedInput = currentInput; cachedOutput = outputFunction.apply(cachedInput); return cachedOutput; }
CachedTransformingSupplier implements Supplier<U> { @Override public synchronized U get() { T currentInput = inputSupplier.get(); if (Objects.equals(cachedInput, currentInput)) { return cachedOutput; } cachedInput = currentInput; cachedOutput = outputFunction.apply(cachedInput); return cachedOutput; } }
CachedTransformingSupplier implements Supplier<U> { @Override public synchronized U get() { T currentInput = inputSupplier.get(); if (Objects.equals(cachedInput, currentInput)) { return cachedOutput; } cachedInput = currentInput; cachedOutput = outputFunction.apply(cachedInput); return cachedOutput; } CachedTransformingSupplier(Supplier<T> inputSupplier, Function<T, U> outputFunction); }
CachedTransformingSupplier implements Supplier<U> { @Override public synchronized U get() { T currentInput = inputSupplier.get(); if (Objects.equals(cachedInput, currentInput)) { return cachedOutput; } cachedInput = currentInput; cachedOutput = outputFunction.apply(cachedInput); return cachedOutput; } CachedTransformingSupplier(Supplier<T> inputSupplier, Function<T, U> outputFunction); @Override synchronized U get(); }
CachedTransformingSupplier implements Supplier<U> { @Override public synchronized U get() { T currentInput = inputSupplier.get(); if (Objects.equals(cachedInput, currentInput)) { return cachedOutput; } cachedInput = currentInput; cachedOutput = outputFunction.apply(cachedInput); return cachedOutput; } CachedTransformingSupplier(Supplier<T> inputSupplier, Function<T, U> outputFunction); @Override synchronized U get();  }