T
- Type held inside closed varpublic class MutableByte extends java.lang.Object implements java.util.function.Supplier<java.lang.Byte>, java.util.function.Consumer<java.lang.Byte>, Matchable.ValueAndOptionalMatcher<java.lang.Byte>
byte var = true;
Runnable r = () -> var =false;
Won't compile because var is treated as if it is final.
This can be 'worked around' by using a wrapping object or array.
e.g.
MutableByte var = MutableByte.of(true);
Runnable r = () -> var.set(false);
Modifier and Type | Class and Description |
---|---|
static interface |
MutableByte.ByteFunction |
Value.ValueImpl<T>
Matchable.AsMatchable, Matchable.AutoCloseableMatchableIterable<TYPE>, Matchable.CheckValue1<T,R>, Matchable.CheckValue2<T1,T2,R>, Matchable.CheckValue3<T1,T2,T3,R>, Matchable.CheckValue4<T1,T2,T3,T4,R>, Matchable.CheckValue5<T1,T2,T3,T4,T5,R>, Matchable.CheckValueOpt<T,R>, Matchable.CheckValues<T,R>, Matchable.MatchableIterable<TYPE>, Matchable.MatchableObject<TYPE>, Matchable.MatchableOptional<T>, Matchable.MatchSelf<TYPE>, Matchable.MTuple1<T1>, Matchable.MTuple2<T1,T2>, Matchable.MTuple3<T1,T2,T3>, Matchable.MTuple4<T1,T2,T3,T4>, Matchable.MTuple5<T1,T2,T3,T4,T5>, Matchable.MXor<T1,T2>, Matchable.ValueAndOptionalMatcher<T>
Convertable.SupplierToConvertable<T>
Constructor and Description |
---|
MutableByte() |
Modifier and Type | Method and Description |
---|---|
void |
accept(java.lang.Byte t) |
static MutableByte |
fromExternal(java.util.function.Supplier<java.lang.Byte> s,
java.util.function.Consumer<java.lang.Byte> c)
Construct a MutableByte that gets and sets an external value using the provided Supplier and Consumer
e.g.
|
java.lang.Byte |
get() |
byte |
getAsByte() |
<T1> Mutable<T1> |
mapInputToObj(java.util.function.Function<T1,java.lang.Byte> fn)
Use the supplied function to perform a lazy map operation when get is called
|
<R> Mutable<R> |
mapOutputToObj(java.util.function.Function<java.lang.Byte,R> fn)
Use the supplied function to perform a lazy map operation when get is called
|
MutableByte |
mutate(MutableByte.ByteFunction varFn) |
static <T> MutableByte |
of(byte var)
Create a Mutable variable, which can be mutated inside a Closure
e.g.
|
MutableByte |
set(byte var) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
iterator, toOptional, visit
matches
convertTo, convertToAsync, fold, fold, generate, getMatchable, iterate, mapReduce, mkString, newSubscriber, of, stream, subscribe, test, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFutureStream, toFutureStream, toIor, toLazyImmutable, toListX, toMaybe, toMutable, toPBagX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toTry, toXor, unapply
foldRight, foldRight, foldRight, foldRightMapToType, join, join, join, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce
from, from, from, from, from, from, from, from, from, from, fromCharSequence, fromIterable, fromOptional, listOfValues, ofDecomposable, otherwise, otherwise, then, then, when, when, when, when, when, when, when, when, when, when, whenGuard, whenTrue, whenValues
fromSupplier, orElse, orElseGet, orElseThrow, toAtomicReference, toCompletableFuture, toCompletableFutureAsync, toCompletableFutureAsync, toFutureW, toList, toOptionalAtomicReference, toStream
public static <T> MutableByte of(byte var)
MutableByte num = MutableByte.of(true);
num.mutate(n->!n))
System.out.println(num.getAsByte());
//prints false
public static MutableByte fromExternal(java.util.function.Supplier<java.lang.Byte> s, java.util.function.Consumer<java.lang.Byte> c)
MutableByte mutable = MutableByte.fromExternal(()->!this.value,val->!this.value);
s
- Supplier of an external valuec
- Consumer that sets an external valuepublic <R> Mutable<R> mapOutputToObj(java.util.function.Function<java.lang.Byte,R> fn)
MutableByte mutable = MutableByte.fromExternal(()->!this.value,val->!this.value);
Mutable<Byte> withOverride = mutable.mapOutputToObj(b->{
if(override)
return 1b;
return b;
});
fn
- Map function to be applied to the result when get is calledpublic <T1> Mutable<T1> mapInputToObj(java.util.function.Function<T1,java.lang.Byte> fn)
MutableByte mutable = MutablByte.fromExternal(()->!this.value,val->!this.value);
Mutable<Byte> withOverride = mutable.mapInputToObj(b->{
if(override)
return 1b;
return b;
});
fn
- Map function to be applied to the input when set is calledpublic byte getAsByte()
public MutableByte set(byte var)
var
- New valuepublic MutableByte mutate(MutableByte.ByteFunction varFn)
varFn
- New valuepublic void accept(java.lang.Byte t)
accept
in interface java.util.function.Consumer<java.lang.Byte>
public java.lang.Byte get()
get
in interface Convertable<java.lang.Byte>
get
in interface java.util.function.Supplier<java.lang.Byte>