/** Maps one {@code Box} to another {@code Box}. */ default <R> Box<R> map(Function<? super T, ? extends R> getMapper, Function<? super R, ? extends T> setMapper) { return Box.from(() -> getMapper.apply(get()), toSet -> set(setMapper.apply(toSet))); }
Box<String> boxFromMethods = Box.from(boxValue::get, boxValue::set);
@Test public void testFromMethods() { Box<String> testValue = Box.ofVolatile(""); Box<String> forValue = Box.from(testValue::get, testValue::set); forValue.set("A"); Assert.assertEquals("A", forValue.get()); forValue.set("B"); Assert.assertEquals("B", forValue.get()); } }