Class UnaryFunction

    • Constructor Detail

      • UnaryFunction

        public UnaryFunction()
    • Method Detail

      • instanceOf

        public static UnaryFunction instanceOf​(java.util.function.Function<java.lang.Object,​? super java.lang.Object> fun)
        Create a UnaryFunction from a lambda expression where the argument can be any Object. For example UnaryFunction.instanceOf(x -> 1.0 / ((Number) x).doubleValue())
        Parameters:
        fun - the lambda function
        Returns:
        a new UnaryFunction instance
        Since:
        Jep 4.0
      • instanceOf

        public static <T> UnaryFunction instanceOf​(java.lang.Class<T> type,
                                                   java.util.function.Function<T,​? super java.lang.Object> fun)
        Create a UnaryFunction from a lambda expression where the argument is of a specified type. For example UnaryFunction.instanceOf(Integer.class, x -> -x ) or using a method reference UnaryFunction.instanceOf(Double.class,Math::cbrt). The eval(Object) method will throw an IllegalParameterException if the argument is not of the correct type.
        Type Parameters:
        T - type of arguments and return value
        Parameters:
        type - type of the arguments
        fun - the lambda function
        Returns:
        a new UnaryFunction instance
        Since:
        Jep 4.0