Class JsArrayConsole

  • All Implemented Interfaces:
    java.util.function.Function<JsPath,​JsFuture<JsArray>>, JsConsole<JsArray>, Program<JsArray>

    public class JsArrayConsole
    extends java.lang.Object
    implements JsConsole<JsArray>, Program<JsArray>
    represents a supplier of a completable future than composes a json array from the user inputs in the standard console. It has the same recursive structure as a json array. Each value of the array has a supplier of a completable future associated that, when executed, prints out its path in the standard console and waits for the user to type in a value and press Enter. When the user fills out all the values, all the futures are completed and a json array is composed.
    • Constructor Detail

      • JsArrayConsole

        public JsArrayConsole()
    • Method Detail

      • tuple

        public static JsArrayConsole tuple​(JsConsole<?> head,
                                           JsConsole<?>... tail)
        static factory method to create a JsArrayIO
        Parameters:
        head - the head
        tail - the tail
        Returns:
        a JsArrayIO
      • exec

        public JsArray exec()
                     throws java.util.concurrent.ExecutionException,
                            java.lang.InterruptedException
        Description copied from interface: Program
        Execute the program
        Specified by:
        exec in interface Program<JsArray>
        Returns:
        a Json
        Throws:
        java.util.concurrent.ExecutionException - if this future completed exceptionally
        java.lang.InterruptedException - if the current thread was interrupted
      • apply

        public JsFuture<JsArray> apply​(JsPath path)
        Specified by:
        apply in interface java.util.function.Function<JsPath,​JsFuture<JsArray>>
        Parameters:
        path - the parent path of the array
        Returns:
        a JsFuture that wen completed will return JsArray
      • promptMessage

        public java.util.function.Consumer<JsPath> promptMessage()
        Specified by:
        promptMessage in interface JsConsole<JsArray>
        Returns:
        consumer that accepts a path and prints out a message indicating to the user that they must type in the value associated to that path