Package jsonvalues

Class MatchFns


  • public class MatchFns
    extends Object
    • 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 JsArray
        ifNotArr - 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 JsBool
        ifNotBoolean - 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 JsDouble
        ifBigDecimal - the function to be applied if this JsElem is a JsBigDec
        ifOther - the function to be applied if this JsElem is a not a decimal JsNumber
        Returns:
        an object of type T