Class IOHandler


  • public abstract class IOHandler
    extends top.focess.command.IOHandler
    This class is used to handle input and output when executing Command.
    • Field Detail

      • SCHEDULER

        protected static final top.focess.scheduler.Scheduler SCHEDULER
    • Constructor Detail

      • IOHandler

        public IOHandler()
    • Method Detail

      • input

        @Nullable
        public <T> T input​(top.focess.command.DataConverter<T> dataConverter)
                    throws top.focess.command.InputTimeoutException
        Used to convert the input String into the target type
        Type Parameters:
        T - the target type
        Parameters:
        dataConverter - the data converter
        Returns:
        the value in the target type or null if the input is not accepted by the dataConverter
        Throws:
        top.focess.command.InputTimeoutException - if the input timeout
      • getConsoleIoHandler

        public static IOHandler getConsoleIoHandler()
      • setConsoleIoHandler

        public static void setConsoleIoHandler​(IOHandler consoleIoHandler)
      • async

        public void async​(java.util.function.Consumer<IOHandler> consumer)
      • outputLang

        public void outputLang​(String key,
                               Object... objects)
        Used to output formatted language key
        Parameters:
        key - the language key
        objects - the objects need to replace
      • hasInput

        public abstract boolean hasInput​(int seconds)
        Indicate there needs an input String and wait for the seconds
        Parameters:
        seconds - the timeout seconds
        Returns:
        true if there is an input String, false otherwise
      • input

        public void input​(@Nullable
                          @Nullable Message message)
      • inputMessage

        public @NonNull Message inputMessage()
                                      throws top.focess.command.InputTimeoutException
        Throws:
        top.focess.command.InputTimeoutException