Package jsonvalues
Class MatchFns
- java.lang.Object
-
- jsonvalues.MatchFns
-
public class MatchFns extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Function<JsElem,T>
ifArrElse(Function<? super JsArray,T> ifArr, Function<? super JsElem,T> ifNotArr)
Declarative way of implementing if(this.isArray()) return ifArr.apply(this.asJsArray()) else return ifNotArr.apply(this)static <T> Function<JsElem,T>
ifBoolElse(Function<? super Boolean,T> ifBoolean, Function<? super JsElem,T> ifNotBoolean)
Declarative way of implementing if(this.isBool()) return ifBoolean.get() else ifNotBoolean.get()static <T> Function<JsElem,T>
ifDecimalElse(DoubleFunction<T> ifDouble, Function<BigDecimal,T> ifBigDecimal, Function<? super JsElem,T> ifOther)
Declarative way of returning an object based on the type of decimal number this element isstatic <T> Function<JsElem,T>
ifIntegralElse(IntFunction<T> ifInt, LongFunction<T> ifLong, Function<BigInteger,T> ifBigInt, Function<? super JsElem,T> ifOther)
static <T> Function<JsElem,T>
ifJsonElse(Function<? super JsObj,T> ifObj, Function<? super JsArray,T> ifArr, Function<? super JsElem,T> ifValue)
static <T> Function<JsElem,T>
ifJsonElse(Function<Json<?>,T> ifJson, Function<JsElem,T> ifNotJson)
static <T> Function<JsElem,T>
ifNothingElse(Supplier<T> nothingSupplier, Function<JsElem,T> elseFn)
static <T> Function<JsElem,T>
ifObjElse(Function<? super JsObj,T> ifObj, Function<? super JsElem,T> ifNotObj)
static <T> Function<JsElem,T>
ifPredicateElse(Predicate<JsElem> predicate, Function<JsElem,T> ifTrue, Function<JsElem,T> ifFalse)
static <T> Function<JsElem,T>
ifStrElse(Function<? super String,T> ifStr, Function<? super JsElem,T> ifNotStr)
static Predicate<JsElem>
isSameType(JsElem that)
-
-
-
Method Detail
-
ifArrElse
public static <T> Function<JsElem,T> ifArrElse(Function<? super JsArray,T> ifArr, Function<? super JsElem,T> ifNotArr)
Declarative way of implementing if(this.isArray()) return ifArr.apply(this.asJsArray()) else return ifNotArr.apply(this)- Type Parameters:
T
- the type of the object returned- Parameters:
ifArr
- the function to be applied if this JsElem is a JsArrayifNotArr
- the function to be applied if this JsElem is not a JsArray- Returns:
- an object of type T
-
ifBoolElse
public static <T> Function<JsElem,T> ifBoolElse(Function<? super Boolean,T> ifBoolean, Function<? super JsElem,T> ifNotBoolean)
Declarative way of implementing if(this.isBool()) return ifBoolean.get() else ifNotBoolean.get()- Type Parameters:
T
- the type of the object returned- Parameters:
ifBoolean
- the function to be applied if this JsElem is a JsBoolifNotBoolean
- the function to be applied if this JsElem is not a JsBool- Returns:
- an object of type T
-
ifDecimalElse
public static <T> Function<JsElem,T> ifDecimalElse(DoubleFunction<T> ifDouble, Function<BigDecimal,T> ifBigDecimal, Function<? super JsElem,T> ifOther)
Declarative way of returning an object based on the type of decimal number this element is- Type Parameters:
T
- the type of the object returned- Parameters:
ifDouble
- the function to be applied if this JsElem is a JsDoubleifBigDecimal
- the function to be applied if this JsElem is a JsBigDecifOther
- the function to be applied if this JsElem is a not a decimal JsNumber- Returns:
- an object of type T
-
ifIntegralElse
public static <T> Function<JsElem,T> ifIntegralElse(IntFunction<T> ifInt, LongFunction<T> ifLong, Function<BigInteger,T> ifBigInt, Function<? super JsElem,T> ifOther)
-
ifJsonElse
public static <T> Function<JsElem,T> ifJsonElse(Function<? super JsObj,T> ifObj, Function<? super JsArray,T> ifArr, Function<? super JsElem,T> ifValue)
-
ifJsonElse
public static <T> Function<JsElem,T> ifJsonElse(Function<Json<?>,T> ifJson, Function<JsElem,T> ifNotJson)
-
ifNothingElse
public static <T> Function<JsElem,T> ifNothingElse(Supplier<T> nothingSupplier, Function<JsElem,T> elseFn)
-
ifObjElse
public static <T> Function<JsElem,T> ifObjElse(Function<? super JsObj,T> ifObj, Function<? super JsElem,T> ifNotObj)
-
ifPredicateElse
public static <T> Function<JsElem,T> ifPredicateElse(Predicate<JsElem> predicate, Function<JsElem,T> ifTrue, Function<JsElem,T> ifFalse)
-
ifStrElse
public static <T> Function<JsElem,T> ifStrElse(Function<? super String,T> ifStr, Function<? super JsElem,T> ifNotStr)
-
-