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