@Override public void accept(final T t) { setOnce(t); }
/** * @param value Create an initialised ImmutableClosedValue with specified value * @return Initialised ImmutableClosedValue */ public static <T> LazyImmutable<T> of(final T value) { final LazyImmutable<T> v = new LazyImmutable<>(); v.setOnce(value); return v; }
@Test public void testSetOnce() { LazyImmutable<Integer> value = new LazyImmutable<>(); Supplier s= () -> value.setOnce(10).get(); assertThat(s.get(),is(10)); assertThat(value.get(),is(10)); } @Test
@Test public void testMap2(){ LazyImmutable<Integer> value = new LazyImmutable<Integer>(); value.setOnce(10); LazyImmutable<Integer> value2 = value.map(i->i+10); assertThat(value2.get(),equalTo(20)); } @Test
@Test public void testFlatMap2(){ LazyImmutable<Integer> value = new LazyImmutable<Integer>(); value.setOnce(10); LazyImmutable<? extends Integer> value2 = value.flatMap(i -> LazyImmutable.of(i + 10)); assertThat(value2.get(),equalTo(20)); } @Test
@Override public void accept(final T t) { setOnce(t); }
/** * @param value Create an initialised ImmutableClosedValue with specified value * @return Initialised ImmutableClosedValue */ public static <T> LazyImmutable<T> of(final T value) { final LazyImmutable<T> v = new LazyImmutable<>(); v.setOnce(value); return v; }
sub.requestOne(); } else { requested.setOnce(true);
sub.requestOne(); } else { requested.setOnce(true);