use of com.oath.cyclops.util.box.MutableFloat in project cyclops by aol.
the class MutableFloatTest method testMutate.
@Test
public void testMutate() {
MutableFloat num = MutableFloat.of(twenty);
Stream.of(1, 2, 3, 4).map(i -> i * 10).peek(i -> num.mutate(n -> new Float((float) (n + i)))).forEach(System.out::println);
assertThat(num.getAsFloat(), is((float) 120));
}
use of com.oath.cyclops.util.box.MutableFloat in project cyclops by aol.
the class MutableFloatTest method inClosure2.
@Test
public void inClosure2() {
MutableFloat myInt = new MutableFloat(zero);
BiFunction<Float, Float, MutableFloat> fn = (i, j) -> myInt.set(new Float((float) (i * j)));
fn.apply(ten, twenty);
assertThat(myInt.getAsFloat(), is((float) 200));
}
use of com.oath.cyclops.util.box.MutableFloat in project cyclops by aol.
the class MutableFloatTest method inClosure.
@Test
public void inClosure() {
MutableFloat myInt = new MutableFloat(zero);
Function<Integer, Function<Integer, MutableFloat>> fn = ((Integer i) -> (Integer j) -> myInt.set(new Float((float) (i * j))));
fn.apply(10).apply(20);
assertThat(myInt.getAsFloat(), is((float) 200));
}
use of com.oath.cyclops.util.box.MutableFloat in project cyclops by aol.
the class MutableFloatTest method externalGet.
@Test
public void externalGet() {
value = 100;
MutableFloat ext = MutableFloat.fromExternal(() -> value, v -> this.value = v);
assertThat(ext.get(), equalTo((float) 100));
}
use of com.oath.cyclops.util.box.MutableFloat in project cyclops by aol.
the class MutableFloatTest method externalSet.
@Test
public void externalSet() {
value = 0;
MutableFloat ext = MutableFloat.fromExternal(() -> value, v -> this.value = v);
ext.set(ten);
assertThat(value, equalTo((float) 10));
}
Aggregations